As a quick review, the CAR algorithm maintains four lists:
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public void | |
| public V | Returns: The calculated return value. May not be nullThe key to add to the cache. If the value
is not found, then the computable will be called to
get the value. May not be null key)The method used to get or add values to this cache |
| public String | Returns: A String containing the values of T1, T2, B1 and B2Returns a string that will contain all the elements of the four lists |
| public int | Returns: The current number of items in the B1 LRUReturns the number of items in the B1 LRU |
| public int | Returns: The current number of items in the B2 LRUReturns the number of items in the B2 LRU |
| public Computable | Returns: The computable associated with this cacheThe computable associated with this cache |
| public double | Returns: The Hit rate from the last time clear was called or 0 if there is no dataReturns the hit rate from the last time clear was called |
| public int | Returns: The current number of key entries in the cacheReturns the current number of keys in the cache. |
| public int | Returns: The maximum size of the cacheGets the current maximum size of the cache (the maximum number of values that will be kept by the cache). |
| public int | Returns: The current value of PReturns the value of p from the CAR algorithm, which is the target size of the t1 clock |
| public int | Returns: The current number of items in the T1 clockReturns the number of items in the T1 clock |
| public int | Returns: The current number of items in the T2 clockReturns the number of items in the T2 clock |
| public int | Returns: The current number of value entries in the cacheReturns the current number of values in the cache. |
| public void | releaseMatching(CacheKeyFilter<K>
A non-null filter that can be used
to delete every key/value pair that matches the filter filter)Releases all key/value pairs that match the filter |
| public boolean | Returns: true if a key was found and removedThe key to remove. May not be null key)Used to remove a single key and value from the cache (if the value is available) |
| clear | back to summary |
|---|---|
| public void clear() Clears the current cache, making the current size zero | |
| clearStaleReferences | back to summary |
|---|---|
| public void clearStaleReferences() Causes stale references to be cleared from the data structures. Since this is a weak cache the references can go away at any time, which happens whenever any operation has been performed. However, it may be the case that no operation will be performed for a while and so this method is provided to have a no-op operation to call in order to clear out any stale references | |
| compute | back to summary |
|---|---|
| public V compute(K key) The method used to get or add values to this cache
| |
| dumpAllLists | back to summary |
|---|---|
| public String dumpAllLists() Returns a string that will contain all the elements of the four lists
| |
| getB1Size | back to summary |
|---|---|
| public int getB1Size() Returns the number of items in the B1 LRU
| |
| getB2Size | back to summary |
|---|---|
| public int getB2Size() Returns the number of items in the B2 LRU
| |
| getComputable | back to summary |
|---|---|
| public Computable The computable associated with this cache
| |
| getHitRate | back to summary |
|---|---|
| public double getHitRate() Returns the hit rate from the last time clear was called
| |
| getKeySize | back to summary |
|---|---|
| public int getKeySize() Returns the current number of keys in the cache. Note that the number of keys can be up to 2x the maximum size of the cache
| |
| getMaxSize | back to summary |
|---|---|
| public int getMaxSize() Gets the current maximum size of the cache (the maximum number of values that will be kept by the cache). Note that the number of keys kept will be 2x, where x is the maximum size of the cache (see CAR algorithm which keeps a key history)
| |
| getP | back to summary |
|---|---|
| public int getP() Returns the value of p from the CAR algorithm, which is the target size of the t1 clock
| |
| getT1Size | back to summary |
|---|---|
| public int getT1Size() Returns the number of items in the T1 clock
| |
| getT2Size | back to summary |
|---|---|
| public int getT2Size() Returns the number of items in the T2 clock
| |
| getValueSize | back to summary |
|---|---|
| public int getValueSize() Returns the current number of values in the cache. Note that the number of values can be up the maximum size of the cache
| |
| releaseMatching | back to summary |
|---|---|
| public void releaseMatching(CacheKeyFilter<K> filter) Releases all key/value pairs that match the filter
| |
| remove | back to summary |
|---|---|
| public boolean remove(K key) Used to remove a single key and value from the cache (if the value is available)
| |