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:
 - Serialized Form
 
 
- 
- 
Nested Class Summary
- 
Nested classes/interfaces inherited from interface org.codehaus.groovy.runtime.memoize.EvictableCache
EvictableCache.EvictionStrategy 
- 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K extends Object,V extends Object> 
- 
Nested classes/interfaces inherited from interface org.codehaus.groovy.runtime.memoize.MemoizeCache
MemoizeCache.ValueProvider<K,V> 
 - 
 
- 
Constructor Summary
Constructors Constructor Description UnlimitedConcurrentCache()Constructs 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
All 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 cacheMap<K,V>clearAll()Clear the cachebooleancontainsKey(Object key)Determines if the cache contains an entry for the specified key.booleancontainsValue(Object value)Set<Map.Entry<K,V>>entrySet()Vget(Object key)Gets a value from the cacheVgetAndPut(K key, MemoizeCache.ValueProvider<? super K,? extends V> valueProvider)The implementation of `getAndPut` is not atomicbooleanisEmpty()Set<K>keys()Get all keys associated to cached valuesSet<K>keySet()Vput(K key, V value)Associates the specified value with the specified key in the cache.voidputAll(Map<? extends K,? extends V> m)Vremove(Object key)Remove the cached value by the keyintsize()Get the size of the cacheCollection<V>values()Get all cached values- 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait 
- 
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAll 
 - 
 
 - 
 
- 
- 
Constructor Detail
- 
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
 
 - 
 
- 
Method Detail
- 
clearAll
public Map<K,V> clearAll()
Clear the cache- Specified by:
 clearAllin interfaceEvictableCache<K,V>- Returns:
 - returns the content of the cleared map
 
 
- 
clear
public void clear()
Clear the cache- Specified by:
 clearin interfaceMap<K,V>- See Also:
 clearAll()
 
- 
values
public Collection<V> values()
Get all cached values 
- 
keys
public Set<K> keys()
Get all keys associated to cached values- Specified by:
 keysin interfaceEvictableCache<K,V>- Returns:
 - all keys
 
 
- 
containsKey
public boolean containsKey(Object key)
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
public boolean containsValue(Object value)
- Specified by:
 containsValuein interfaceMap<K,V>
 
- 
size
public int size()
Get the size of the cache 
- 
put
public V put(K key, V value)
Associates the specified value with the specified key in the cache. 
- 
getAndPut
public V getAndPut(K key, MemoizeCache.ValueProvider<? super K,? extends V> valueProvider)
The implementation of `getAndPut` is not atomic- Specified by:
 getAndPutin interfaceMemoizeCache<K,V>- 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>
 
 - 
 
 -