Inheritance diagram for VirtualCache:
Public Member Functions | |
this (IBitBucket bucket, uint capacity, uint concurrency=16) | |
IBitBucket | getBucket () |
IPayload | get (char[] key) |
IPayload | extract (char[] key, ulong timeLimit=ulong.max) |
IPayload | put (char[] key, IPayload entry) |
Private Member Functions | |
this (uint capacity, uint concurrency=16) | |
IPayload | extract (char[] key) |
QueuedEntry | createQueuedEntry (char[] key, IPayload entry) |
Private Attributes | |
Buffer | buffer |
IBitBucket | bucket |
PickleReader | reader |
PickleWriter | writer |
Here's a contrived example:
// create a FileBucket as a place to spill cache entries auto FileBucket bucket = new FileBucket (new FilePath("bucket.bin"), FileBucket.HalfK); // note that we specify only two entries, to ensure we'll spill // entries to the FileBucket VirtualCache cache = new VirtualCache (bucket, 2); // need to tell registry how to resurrect our spilled entries PickleRegistry.enroll (new Payload); // stuff a few entries into the cache. Adding the third entry // will cause a spillover to the FileBucket cache.put ("a", new Payload); cache.put ("b", new Payload); cache.put ("c", new Payload); // retrieve entries such that we cause one more spillage and // two resurrections assert (cache.get("a")); assert (cache.get("c")); assert (cache.get("b"));
Definition at line 89 of file VirtualCache.d.
|
Create a VirtualCache with the provided IBitBucket and maximum capacity. Said capacity sets the waterline mark whereby further additions to the cache will cause least recently used entries to be spilled to the IBitBucket. The concurrency level indicates approximately how many threads will content for write access at one time. Definition at line 107 of file VirtualCache.d. References bucket, buffer, IBitBucket::getBufferSize(), PickleReader, PickleWriter, reader, and writer. |
|
Return the IBitBucket used by this VirtualCache Definition at line 132 of file VirtualCache.d. References bucket. |
|
Return an entry from this cache. If the given key is not found, we attempt to resurrect the entry via data from our IBitBucket. Returns the IPayload upon success, null if the given key was never placed into the cache. Reimplemented from QueuedCache. Definition at line 148 of file VirtualCache.d. References bucket, IBitBucket::get(), reader, and PickleReader::thaw(). Referenced by testVirtualCache(). |
|
Remove an entry from this cache, and from the associated IBitBucket too. Reimplemented from QueuedCache. Definition at line 177 of file VirtualCache.d. References bucket, and IBitBucket::remove(). |
|
Place an entry into the cache and associate it with the provided key. Note that there can be only one entry for any particular key. If two keys entries are added with the same key, the second one overwrites the first. Copy entry to Bucket immediately, so we avoid writing it each time it gets bumped from the cache. Reimplemented from QueuedCache. Definition at line 200 of file VirtualCache.d. References bucket, buffer, Buffer::clear(), PickleWriter::freeze(), IBitBucket::put(), Buffer::toString(), and writer. Referenced by testVirtualCache(). |
|
Construct a cache with the specified maximum number of entries. Additions to the cache beyond this number will reuse the slot of the least-recently-referenced cache entry. The concurrency level indicates approximately how many threads will content for write access at one time. Reimplemented from PlainCache. Definition at line 79 of file QueuedCache.d. References QueuedCache::capacity. |
|
Remove (and return) the cache entry associated with the provided key. Returns null if there is no such entry. Definition at line 105 of file PlainCache.d. References HashMap::remove(). Referenced by testPlainCache(). |
|
Overridable factory for creating list entries. Definition at line 167 of file QueuedCache.d. |
|
Definition at line 91 of file VirtualCache.d. |
|
Definition at line 92 of file VirtualCache.d. Referenced by extract(), get(), getBucket(), put(), and this(). |
|
Definition at line 93 of file VirtualCache.d. |
|
Definition at line 94 of file VirtualCache.d. |