Class UnlimitedConcurrentCache<K,V>
- java.lang.Object
- 
- org.codehaus.groovy.runtime.memoize.UnlimitedConcurrentCache<K,V>
 
- 
- All Implemented Interfaces:
- java.io.Serializable,- java.util.Map<K,V>,- EvictableCache<K,V>,- MemoizeCache<K,V>
 
 @ThreadSafe public final class UnlimitedConcurrentCache<K,V> extends java.lang.Object implements EvictableCache<K,V>, java.io.Serializable A cache backed by a ConcurrentHashMap- See Also:
- Serialized Form
 
- 
- 
Nested Class Summary- 
Nested classes/interfaces inherited from interface org.codehaus.groovy.runtime.memoize.EvictableCacheEvictableCache.EvictionStrategy
 - 
Nested classes/interfaces inherited from interface java.util.Mapjava.util.Map.Entry<K extends java.lang.Object,V extends java.lang.Object>
 - 
Nested classes/interfaces inherited from interface org.codehaus.groovy.runtime.memoize.MemoizeCacheMemoizeCache.ValueProvider<K,V>
 
- 
 - 
Constructor SummaryConstructors Constructor Description UnlimitedConcurrentCache()Constructs a cache with unlimited sizeUnlimitedConcurrentCache(int initialCapacity)Constructs a cache with unlimited size and set its initial capacityUnlimitedConcurrentCache(java.util.Map<? extends K,? extends V> m)Constructs a cache and initialize the cache with the specified map
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcleanUpNullReferences()Replying on the ConcurrentHashMap thread-safe iteration implementation the method will remove all entries holding SoftReferences to gc-evicted objects.voidclear()Clear the cachejava.util.Map<K,V>clearAll()Clear the cachebooleancontainsKey(java.lang.Object key)Determines if the cache contains an entry for the specified key.booleancontainsValue(java.lang.Object value)java.util.Set<java.util.Map.Entry<K,V>>entrySet()Vget(java.lang.Object key)Gets a value from the cacheVgetAndPut(K key, MemoizeCache.ValueProvider<? super K,? extends V> valueProvider)The implementation of `getAndPut` is not atomicbooleanisEmpty()java.util.Set<K>keys()Get all keys associated to cached valuesjava.util.Set<K>keySet()Vput(K key, V value)Associates the specified value with the specified key in the cache.voidputAll(java.util.Map<? extends K,? extends V> m)Vremove(java.lang.Object key)Remove the cached value by the keyintsize()Get the size of the cachejava.util.Collection<V>values()Get all cached values
 
- 
- 
- 
Constructor Detail- 
UnlimitedConcurrentCachepublic UnlimitedConcurrentCache() Constructs a cache with unlimited size
 - 
UnlimitedConcurrentCachepublic UnlimitedConcurrentCache(int initialCapacity) Constructs a cache with unlimited size and set its initial capacity- Parameters:
- initialCapacity- the initial capacity
 
 
- 
 - 
Method Detail- 
removepublic V remove(java.lang.Object key) Remove the cached value by the key
 - 
clearAllpublic java.util.Map<K,V> clearAll() Clear the cache- Specified by:
- clearAllin interface- EvictableCache<K,V>
- Returns:
- returns the content of the cleared map
 
 - 
clearpublic void clear() Clear the cache- Specified by:
- clearin interface- java.util.Map<K,V>
- See Also:
- clearAll()
 
 - 
valuespublic java.util.Collection<V> values() Get all cached values
 - 
keyspublic java.util.Set<K> keys() Get all keys associated to cached values- Specified by:
- keysin interface- EvictableCache<K,V>
- Returns:
- all keys
 
 - 
containsKeypublic boolean containsKey(java.lang.Object key) Determines if the cache contains an entry for the specified key.- Specified by:
- containsKeyin interface- EvictableCache<K,V>
- Specified by:
- containsKeyin interface- java.util.Map<K,V>
- Parameters:
- key- key whose presence in this cache is to be tested.
- Returns:
- true if the cache contains a mapping for the specified key
 
 - 
containsValuepublic boolean containsValue(java.lang.Object value) 
 - 
sizepublic int size() Get the size of the cache
 - 
putpublic V put(K key, V value) Associates the specified value with the specified key in the cache.- Specified by:
- putin interface- java.util.Map<K,V>
- Specified by:
- putin interface- MemoizeCache<K,V>
- Parameters:
- key- key with which the specified value is to be associated
- value- value to be associated with the specified key
- Returns:
- null, or the old value if the key associated with the specified key.
 
 - 
getpublic V get(java.lang.Object key) Gets a value from the cache
 - 
getAndPutpublic V getAndPut(K key, MemoizeCache.ValueProvider<? super K,? extends V> valueProvider) The implementation of `getAndPut` is not atomic- Specified by:
- getAndPutin interface- MemoizeCache<K,V>
- Returns:
- the cached value
 
 - 
cleanUpNullReferencespublic void cleanUpNullReferences() Replying on the ConcurrentHashMap thread-safe iteration implementation the method will remove all entries holding SoftReferences to gc-evicted objects.- Specified by:
- cleanUpNullReferencesin interface- MemoizeCache<K,V>
 
 
- 
 
-