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 Summary
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 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 Summary
Modifier and TypeMethodDescriptionvoidReplying on the ConcurrentHashMap thread-safe iteration implementation the method will remove all entries holding SoftReferences to gc-evicted objects.voidclear()Clear the cacheclearAll()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) The implementation of `getAndPut` is not atomicbooleanisEmpty()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 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
-
UnlimitedConcurrentCache
public UnlimitedConcurrentCache()Constructs a cache with unlimited size -
UnlimitedConcurrentCache
public UnlimitedConcurrentCache(int initialCapacity) Constructs a cache with unlimited size and set its initial capacity- Parameters:
initialCapacity- the initial capacity
-
UnlimitedConcurrentCache
-
-
Method Details
-
remove
-
putAll
-
keySet
-
clearAll
-
clear
-
values
Get all cached values -
entrySet
-
keys
-
containsKey
Determines if the cache contains an entry for the specified key.- Specified by:
containsKeyin interfaceEvictableCache<K,V> - Specified by:
containsKeyin interfaceMap<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 interfaceMap<K,V>
-
size
-
isEmpty
-
put
Associates the specified value with the specified key in the cache. -
get
-
getAndPut
The implementation of `getAndPut` is not atomic- Specified by:
getAndPutin interfaceMemoizeCache<K,V> - Parameters:
key-- Returns:
- the cached value
-
cleanUpNullReferences
public 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 interfaceMemoizeCache<K,V>
-