KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: What's in the Cache?
PRODUCT: 4D | VERSION: 12 | PLATFORM: Mac & Win
Published On: June 9, 2011

The cache is a critical part of 4D. To understand just how critical it is, it is important to understand exactly what the cache is and what it contains.

Note that the information in this Tech Tip is not unique to 4D v12, so it is useful in understanding previous versions of 4D as well.

In simple terms the cache is nothing more than a large chunk of memory that is managed by 4D. However even in this simple description there is an important fact: the OS does not manage this memory, 4D does. The idea is that 4D is in full control of the content of this memory.

The 4D cache is really not like a hardware cache at all. It's true, hardware caches are designed to store content from a slower medium inside a faster one. The cache in 4D is, partially, designed to store disk content in RAM. For example, records and indexes are loaded into the cache from disk. However the cache is not just for data file objects. It is also used for all kinds of data engine objects (selections, transactions, sorting data, etc) and even structure objects (table definitions, forms, methods, etc.). In this sense the cache is not just about performance but also integrity.

Here is a non-exhaustive list of the kind of objects that are kept in the cache:

  • Structural definitions of tables, fields, relations, indexes, etc.
  • General information about opened databases (file paths, properties, etc.)
  • Data file allocation bit tables
  • Address tables for records, indexes, blobs, extra properties, etc.
  • Index pages
  • Records
  • BLOBs (may be allocated in main memory instead if not enough space in cache)
  • Extra properties
  • Sequence numbers
  • Transactions
  • Selections
  • Sets
  • Temporary buffers for sorting, read ahead, buffered disk write, etc.

As you can imagine, 4D is constantly managing this memory, juggling different kinds of objects in order to keep things as efficient as possible. This is why the cache is so critical to the functioning of 4D.