Class UnlimitedConcurrentCache<K,V> 
java.lang.Object
org.codehaus.groovy.runtime.memoize.UnlimitedConcurrentCache<K,V> 
- All Implemented Interfaces:
- Serializable,- Map<K,,- V> - EvictableCache<K,,- V> - MemoizeCache<K,- V> 
@ThreadSafe
public final class UnlimitedConcurrentCache<K,V> 
extends Object
implements EvictableCache<K,V>, Serializable 
A cache backed by a ConcurrentHashMap
- See Also:
- 
Nested Class SummaryNested classes/interfaces inherited from interface org.codehaus.groovy.runtime.memoize.EvictableCacheEvictableCache.Action<K,V, R>, EvictableCache.EvictionStrategy Nested classes/interfaces inherited from interface java.util.MapMap.Entry<K extends Object,V extends Object> Nested classes/interfaces inherited from interface org.codehaus.groovy.runtime.memoize.MemoizeCacheMemoizeCache.ValueProvider<K,V> 
- 
Constructor SummaryConstructorsConstructorDescriptionConstructs a cache with unlimited sizeUnlimitedConcurrentCache(int initialCapacity) Constructs a cache with unlimited size and set its initial capacityUnlimitedConcurrentCache(Map<? extends K, ? extends V> m) Constructs a cache and initialize the cache with the specified map
- 
Method SummaryModifier and TypeMethodDescriptionvoidReplying on the ConcurrentHashMap thread-safe iteration implementation the method will remove all entries holding SoftReferences to gc-evicted objects.clearAll()Clear the cachebooleancontainsKey(Object key) Determines if the cache contains an entry for the specified key.booleancontainsValue(Object value) entrySet()Gets a value from the cachegetAndPut(K key, MemoizeCache.ValueProvider<? super K, ? extends V> valueProvider) Try to get the value from cache.booleanisEmpty()keys()Get all keys associated to cached valueskeySet()Associates the specified value with the specified key in the cache.voidRemove the cached value by the keyintsize()Get the size of the cachevalues()Get all cached valuesMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.codehaus.groovy.runtime.memoize.EvictableCacheclearMethods inherited from interface java.util.Mapcompute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAll
- 
Constructor Details- 
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
 
- 
UnlimitedConcurrentCacheConstructs a cache and initialize the cache with the specified map- Parameters:
- m- the map to initialize the cache
 
 
- 
- 
Method Details- 
removeRemove the cached value by the key
- 
putAll
- 
keySet
- 
clearAllClear the cache- Specified by:
- clearAllin interface- EvictableCache<K,- V> 
- Returns:
- returns the content of the cleared map
 
- 
valuesGet all cached values
- 
entrySet
- 
keysGet all keys associated to cached values- Specified by:
- keysin interface- EvictableCache<K,- V> 
- Returns:
- all keys
 
- 
containsKeyDetermines if the cache contains an entry for the specified key.- Specified by:
- containsKeyin interface- EvictableCache<K,- V> 
- Specified by:
- containsKeyin interface- 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
 
- 
containsValue- Specified by:
- containsValuein interface- Map<K,- V> 
 
- 
sizepublic int size()Get the size of the cache
- 
isEmptypublic boolean isEmpty()
- 
putAssociates the specified value with the specified key in the cache.
- 
getGets a value from the cache
- 
getAndPutTry to get the value from cache. If not found, create the value byMemoizeCache.ValueProviderand put it into the cache, at last return the value.- Specified by:
- getAndPutin interface- MemoizeCache<K,- V> 
- Parameters:
- key-
- valueProvider- provide the value if the associated value not found
- 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> 
 
 
-