The Cache class is an abstract superclass which allows keeping objects in RAM until the next garbage allocation (Allocator::free().
In practice many objects stay around taking up RAM until GC, so we might as well use them. For example, if a Message is used several times in quick succession, why shouldn't we use the copy that actually is there in RAM?
Subclasses of Cache have to provide cache insertion and retrieval. This class provides only one bit of core functionality, namely clearing the cache at GC time.
Constructs an empty Cache. This constructor makes sure the object will not be freed during garbage collection, and that clear() will be called when appropriate.
f is the duration factor of this cache; it will be cleared once every f garbage collections. It should be low for expensive caches and for ones whose objects will stale quickly, large (say 5-10) for cheap ones whose objects stale slowly.
= 0; Implemented by subclasses to discards the contents of the cache.
Destroys the cache and ensures that clear() won't be called any more.
This web page based on source code belonging to The Archiveopteryx Developers. All rights reserved.