home *** CD-ROM | disk | FTP | other *** search
- Tech Chapter 5 - Internal cache MetalBase 5.1
- -------------------------------------------------------------------------------
-
- Since MetalBase is not written around a client-server model, records cannot
- be cached in between function calls... if they were did, there's a good
- possibility that another process would modify the relation while we were
- idle, invalidating our cache.
-
- Actually, that's a rather inaccurate argument. The truth is that records could
- conceivably be cached between operations, with only one improvement
- required: when an operation which uses the cache is performed, a strobe
- byte should be incremented somewhere in the relation... and the calling
- process should store the new number in the appropriate relation* structure.
- The cache would be flushed but not cleared after each operation. When the
- next request is made, the number would be checked; if they weren't the same,
- the cache would be cleared, otherwise, no operation took place and the cache
- should still be valid. To prove useful, though, this would require that
- each index have its own cache...
-
- But that's for a later release, and I'm getting away from the point of this
- chapter. Because we don't/can't cache between operations, we instead
- cache data during the slowest internal operation: rebalancing.
-
- The nature of rebalancing is that it reads and modifies a single record many,
- many times over. To speed up this process, MetalBase reads records through
- a cache; if the record requested doesn't exist in the cache, it is read in;
- at that point, a pointer into the cache is returned. Any modifications
- are made to the cache, which is flushed when it becomes full or when the
- operation requires it.
-
- This is a very basic cache--rebalancing doesn't require that the actual records
- be checked, just the pointers for the indices. The top-of-index pointer
- is also cached.
-
- The entire cache (500 records' worth of it, as 5.1 is shipped) is available for
- each index to be worked upon in turn. Unfortunately, this means two things:
-
- 1st: If a system such as the one I rambled on about earlier is
- implemented, only a single index could have information
- retained. This would have to change.
-
- 2nd: MetalBase makes two or three passes through the list of
- indices before completing an add, update or delete operation;
- the first passes are read-only, but the data that is read in
- does not remain in the cache during the next stage.
-
- See the comments in the source code [mb_cache.c] for more information regarding
- the implementation of MetalBase's internal cache.
-
-