K - type of the keysV - type of the values@ThreadSafe public class StampedCommonCache<K,V> extends Object implements EvictableCache<K,V>, ValueConvertable<V,Object>, Serializable
Map instance.
 StampedCommonCache has better performance than ConcurrentCommonCache,
 but it is not reentrant, in other words, it may cause deadlock if getAndPut(Object, MemoizeCache.ValueProvider)
 or getAndPut(Object, MemoizeCache.ValueProvider, boolean) is called recursively:
 readlock -> upgrade to writelock -> readlock (fails to get and waits forever)EvictableCache.Action<K,V,R>, EvictableCache.EvictionStrategyMemoizeCache.ValueProvider<K,V>| Constructor and Description | 
|---|
StampedCommonCache()
Constructs a cache with unlimited size 
 | 
StampedCommonCache(int maxSize)
Constructs a LRU cache with the default initial capacity(16) 
 | 
StampedCommonCache(int initialCapacity,
                  int maxSize)
Constructs a LRU cache with the specified initial capacity and max size. 
 | 
StampedCommonCache(int initialCapacity,
                  int maxSize,
                  EvictableCache.EvictionStrategy evictionStrategy)
Constructs a cache with limited size 
 | 
StampedCommonCache(Map<K,V> map)
Constructs a cache backed by the specified  
Map instance | 
| Modifier and Type | Method and Description | 
|---|---|
void | 
cleanUpNullReferences()
Invoked when some of the held SoftReferences have been evicted by the garbage collector and so should be removed from the cache. 
 | 
Map<K,V> | 
clearAll()
Clear the cache 
 | 
boolean | 
containsKey(Object key)
Determines if the cache contains an entry for the specified key. 
 | 
boolean | 
containsValue(Object value)  | 
Object | 
convertValue(V value)
convert the original value to the target value 
 | 
Set<Map.Entry<K,V>> | 
entrySet()  | 
V | 
get(Object 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 | 
getAndPut(K key,
         MemoizeCache.ValueProvider<? super K,? extends V> valueProvider,
         boolean shouldCache)  | 
boolean | 
isEmpty()  | 
Set<K> | 
keys()
Get all keys associated to cached values 
 | 
Set<K> | 
keySet()  | 
V | 
put(K key,
   V value)
Associates the specified value with the specified key in the cache. 
 | 
void | 
putAll(Map<? extends K,? extends V> m)  | 
V | 
remove(Object key)
Remove the cached value by the key 
 | 
int | 
size()
Get the size of the cache 
 | 
Collection<V> | 
values()
Get all cached values 
 | 
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitclearcompute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAllpublic StampedCommonCache()
public StampedCommonCache(int initialCapacity,
                          int maxSize,
                          EvictableCache.EvictionStrategy evictionStrategy)
initialCapacity - initial capacity of the cachemaxSize - max size of the cacheevictionStrategy - LRU or FIFO, see EvictableCache.EvictionStrategypublic StampedCommonCache(int initialCapacity,
                          int maxSize)
LRUCacheinitialCapacity - initial capacity of the LRU cachemaxSize - max size of the LRU cachepublic StampedCommonCache(int maxSize)
maxSize - max size of the LRU cacheStampedCommonCache(int, int)public V put(K key, V value)
public V getAndPut(K key, MemoizeCache.ValueProvider<? super K,? extends V> valueProvider)
MemoizeCache.ValueProvider and put it into the cache, at last return the value.getAndPut in interface MemoizeCache<K,V>valueProvider - provide the value if the associated value not foundpublic V getAndPut(K key, MemoizeCache.ValueProvider<? super K,? extends V> valueProvider, boolean shouldCache)
public Collection<V> values()
public Set<K> keys()
keys in interface EvictableCache<K,V>public boolean containsKey(Object key)
containsKey in interface Map<K,V>containsKey in interface EvictableCache<K,V>key - key whose presence in this cache is to be tested.public boolean containsValue(Object value)
containsValue in interface Map<K,V>public int size()
public Map<K,V> clearAll()
clearAll in interface EvictableCache<K,V>public void cleanUpNullReferences()
cleanUpNullReferences in interface MemoizeCache<K,V>public Object convertValue(V value)
convertValue in interface ValueConvertable<V,Object>value - the original value