@ThreadSafe public final class LRUCache<K,V> extends Object implements MemoizeCache<K,V>
MemoizeCache.ValueProvider<K,V>| Constructor and Description |
|---|
LRUCache(int maxCacheSize) |
| Modifier and Type | Method and Description |
|---|---|
void |
cleanUpNullReferences()
Remove all entries holding SoftReferences to gc-evicted objects.
|
V |
get(K key)
Gets a value from the cache
|
V |
getAndPut(K key,
MemoizeCache.ValueProvider<? super K,? extends V> valueProvider)
Try to get the value from cache.
|
V |
put(K key,
V value)
Associates the specified value with the specified key in the cache.
|
public V put(K key, V value)
MemoizeCacheput in interface MemoizeCache<K,V>key - key with which the specified value is to be associatedvalue - value to be associated with the specified keypublic V get(K key)
MemoizeCacheget in interface MemoizeCache<K,V>key - the key whose associated value is to be returnedpublic V getAndPut(K key, MemoizeCache.ValueProvider<? super K,? extends V> valueProvider)
MemoizeCache.ValueProvider and put it into the cache, at last return the value.
The operation is completed atomically.getAndPut in interface MemoizeCache<K,V>key - valueProvider - provide the value if the associated value not foundpublic void cleanUpNullReferences()
cleanUpNullReferences in interface MemoizeCache<K,V>