Class ConcurrentSoftCache<K,V>
java.lang.Object
org.codehaus.groovy.runtime.memoize.ConcurrentCommonCache<K, SoftReference<V>>
org.codehaus.groovy.runtime.memoize.ConcurrentSoftCache<K,V>
- Type Parameters:
K- key typeV- real value type
- All Implemented Interfaces:
Serializable, Map<K, SoftReference<V>>, EvictableCache<K, SoftReference<V>>, MemoizeCache<K, SoftReference<V>>, ValueConvertable<SoftReference<V>, Object>
Represents concurrent cache holding SoftReference instance as value
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class ConcurrentCommonCache
ConcurrentCommonCache.Action<K,V, R> Nested classes/interfaces inherited from interface EvictableCache
EvictableCache.EvictionStrategyNested classes/interfaces inherited from interface MemoizeCache
MemoizeCache.ValueProvider<K,V> -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a cache with unlimited sizeConcurrentSoftCache(int maxSize) Constructs a LRU cache with the default initial capacity(16)ConcurrentSoftCache(int initialCapacity, int maxSize) Constructs a LRU cache with the specified initial capacity and max size.ConcurrentSoftCache(int initialCapacity, int maxSize, EvictableCache.EvictionStrategy evictionStrategy) Constructs a cache with limited sizeConcurrentSoftCache(Map<K, SoftReference<V>> map) Constructs a cache backed by the specifiedMapinstance -
Method Summary
Modifier and TypeMethodDescriptionconvertValue(SoftReference<V> value) convert the original value to the target valueMethods inherited from class ConcurrentCommonCache
cleanUpNullReferences, clear, clearAll, containsKey, containsValue, entrySet, get, getAndPut, getAndPut, isEmpty, keys, keySet, put, putAll, remove, size, valuesMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Map
compute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Constructor Details
-
ConcurrentSoftCache
public ConcurrentSoftCache()Constructs a cache with unlimited size -
ConcurrentSoftCache
public ConcurrentSoftCache(int initialCapacity, int maxSize, EvictableCache.EvictionStrategy evictionStrategy) Constructs a cache with limited size- Parameters:
initialCapacity- initial capacity of the cachemaxSize- max size of the cacheevictionStrategy- LRU or FIFO, seeEvictableCache.EvictionStrategy
-
ConcurrentSoftCache
public ConcurrentSoftCache(int initialCapacity, int maxSize) Constructs a LRU cache with the specified initial capacity and max size. The LRU cache is slower thanLRUCache- Parameters:
initialCapacity- initial capacity of the LRU cachemaxSize- max size of the LRU cache
-
ConcurrentSoftCache
public ConcurrentSoftCache(int maxSize) Constructs a LRU cache with the default initial capacity(16)- Parameters:
maxSize- max size of the LRU cache- See Also:
-
ConcurrentSoftCache
-
-
Method Details
-
convertValue
convert the original value to the target value- Specified by:
convertValuein interfaceValueConvertable<K,V> - Overrides:
convertValuein classConcurrentCommonCache<K, SoftReference<V>>- Parameters:
value- the original value- Returns:
- the converted value
-