Class ConcurrentSoftCache<K,V>
- java.lang.Object
-
- org.codehaus.groovy.runtime.memoize.ConcurrentCommonCache<K,java.lang.ref.SoftReference<V>>
-
- org.codehaus.groovy.runtime.memoize.ConcurrentSoftCache<K,V>
-
- Type Parameters:
K- key typeV- real value type
- All Implemented Interfaces:
java.io.Serializable,java.util.Map<K,java.lang.ref.SoftReference<V>>,EvictableCache<K,java.lang.ref.SoftReference<V>>,MemoizeCache<K,java.lang.ref.SoftReference<V>>,ValueConvertable<java.lang.ref.SoftReference<V>,java.lang.Object>
public class ConcurrentSoftCache<K,V> extends ConcurrentCommonCache<K,java.lang.ref.SoftReference<V>>
Represents concurrent cache holding SoftReference instance as value- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.codehaus.groovy.runtime.memoize.ConcurrentCommonCache
ConcurrentCommonCache.Action<K,V,R>
-
Nested classes/interfaces inherited from interface org.codehaus.groovy.runtime.memoize.EvictableCache
EvictableCache.EvictionStrategy
-
Nested classes/interfaces inherited from interface java.util.Map
java.util.Map.Entry<K extends java.lang.Object,V extends java.lang.Object>
-
Nested classes/interfaces inherited from interface org.codehaus.groovy.runtime.memoize.MemoizeCache
MemoizeCache.ValueProvider<K,V>
-
-
Constructor Summary
Constructors Constructor Description ConcurrentSoftCache()Constructs 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(java.util.Map<K,java.lang.ref.SoftReference<V>> map)Constructs a cache backed by the specifiedMapinstance
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.ObjectconvertValue(java.lang.ref.SoftReference<V> value)convert the original value to the target value-
Methods inherited from class org.codehaus.groovy.runtime.memoize.ConcurrentCommonCache
cleanUpNullReferences, clear, clearAll, containsKey, containsValue, entrySet, get, getAndPut, getAndPut, isEmpty, keys, keySet, put, putAll, remove, size, values
-
-
-
-
Constructor Detail
-
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(int, int)
-
-
Method Detail
-
convertValue
public java.lang.Object convertValue(java.lang.ref.SoftReference<V> value)
convert the original value to the target value- Specified by:
convertValuein interfaceValueConvertable<K,V>- Overrides:
convertValuein classConcurrentCommonCache<K,java.lang.ref.SoftReference<V>>- Parameters:
value- the original value- Returns:
- the converted value
-
-