public class WeakCARCacheImpl<K,V> extends Object implements WeakCARCache<K,V>
Constructor and Description |
---|
WeakCARCacheImpl(Computable<K,V> computable,
int maxSize,
boolean isWeak) |
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clears the current cache, making the current size zero
|
void |
clearStaleReferences()
Causes stale references to be cleared from the data
structures.
|
V |
compute(K key)
The method used to get or add values to this cache
|
String |
dumpAllLists()
Returns a string that will contain all the elements of the four lists
|
int |
getB1Size()
Returns the number of items in the B1 LRU
|
int |
getB2Size()
Returns the number of items in the B2 LRU
|
Computable<K,V> |
getComputable()
The computable associated with this cache
|
double |
getHitRate()
Returns the hit rate from the last time clear was called
|
int |
getKeySize()
Returns the current number of keys in the cache.
|
int |
getMaxSize()
Gets the current maximum size of the cache (the maximum
number of values that will be kept by the cache).
|
int |
getP()
Returns the value of p from the CAR algorithm, which
is the target size of the t1 clock
|
int |
getT1Size()
Returns the number of items in the T1 clock
|
int |
getT2Size()
Returns the number of items in the T2 clock
|
int |
getValueSize()
Returns the current number of values in the cache.
|
void |
releaseMatching(CacheKeyFilter<K> filter)
Releases all key/value pairs that match the filter
|
boolean |
remove(K key)
Used to remove a single key and value from the cache (if
the value is available)
|
String |
toString() |
public WeakCARCacheImpl(Computable<K,V> computable, int maxSize, boolean isWeak)
public V compute(K key)
WeakCARCache
compute
in interface WeakCARCache<K,V>
key
- The 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 nullpublic int getKeySize()
WeakCARCache
getKeySize
in interface WeakCARCache<K,V>
public int getValueSize()
WeakCARCache
getValueSize
in interface WeakCARCache<K,V>
public void clear()
WeakCARCache
clear
in interface WeakCARCache<K,V>
public int getMaxSize()
WeakCARCache
getMaxSize
in interface WeakCARCache<K,V>
public Computable<K,V> getComputable()
WeakCARCache
getComputable
in interface WeakCARCache<K,V>
public boolean remove(K key)
WeakCARCache
remove
in interface WeakCARCache<K,V>
key
- The key to remove. May not be nullpublic void releaseMatching(CacheKeyFilter<K> filter)
WeakCARCache
releaseMatching
in interface WeakCARCache<K,V>
filter
- A non-null filter that can be used
to delete every key/value pair that matches the filterpublic void clearStaleReferences()
WeakCARCache
clearStaleReferences
in interface WeakCARCache<K,V>
public int getT1Size()
WeakCARCache
getT1Size
in interface WeakCARCache<K,V>
public int getT2Size()
WeakCARCache
getT2Size
in interface WeakCARCache<K,V>
public int getB1Size()
WeakCARCache
getB1Size
in interface WeakCARCache<K,V>
public int getB2Size()
WeakCARCache
getB2Size
in interface WeakCARCache<K,V>
public int getP()
WeakCARCache
getP
in interface WeakCARCache<K,V>
public String dumpAllLists()
WeakCARCache
dumpAllLists
in interface WeakCARCache<K,V>
public double getHitRate()
WeakCARCache
getHitRate
in interface WeakCARCache<K,V>
Copyright © 2009-2017, Oracle and/or its affiliates. All Rights Reserved.