Cache flip
The previous desicussion of the cache design skipped the larger design: The cache is actually two tables, NEW and OLD.
The NEW cache gets priority. And new data is only added the the NEW cache.
In this case, the 28.CC03 presence was only on the old cache.
Gradually the OLD cache will become increasingly stale and irrelevant.
- New data is never added to the OLD cache
- Updated values in the NEW cache will hide the old data
- Even the most stable old data eventually times out.
When the OLD cache is entirely expired:
The OLD cache is now useless. We can
- Clear the OLD cache
- Make the NEW cache "OLD" (stop adding data).
- Create a clean NEW cache.
This is the FLIP.
The advantages for this design are:
- No scans for old data need to be done.
- No separate cache management process or thread is needed.
- No cache activity occurs except when a 1-wire program is queried (better for hardware hibernation).
- The risk of memory leaks is minimized.
Previous page: Cache objects
Next page: Remote cache