@ThreadSafe public final class UnlimitedConcurrentCache<K,V> extends java.lang.Object implements EvictableCache<K,V>, java.io.Serializable
EvictableCache.EvictionStrategy
MemoizeCache.ValueProvider<K,V>
Constructor and Description |
---|
UnlimitedConcurrentCache()
Constructs a cache with unlimited size
|
UnlimitedConcurrentCache(int initialCapacity)
Constructs a cache with unlimited size and set its initial capacity
|
UnlimitedConcurrentCache(java.util.Map<? extends K,? extends V> m)
Constructs a cache and initialize the cache with the specified map
|
Modifier and Type | Method and Description |
---|---|
void |
cleanUpNullReferences()
Replying on the ConcurrentHashMap thread-safe iteration implementation the method will remove all entries holding
SoftReferences to gc-evicted objects.
|
void |
clear()
Clear the cache
|
java.util.Map<K,V> |
clearAll()
Clear the cache
|
boolean |
containsKey(java.lang.Object key)
Determines if the cache contains an entry for the specified key.
|
boolean |
containsValue(java.lang.Object value) |
java.util.Set<java.util.Map.Entry<K,V>> |
entrySet() |
V |
get(java.lang.Object key)
Gets a value from the cache
|
V |
getAndPut(K key,
MemoizeCache.ValueProvider<? super K,? extends V> valueProvider)
The implementation of `getAndPut` is not atomic
|
boolean |
isEmpty() |
java.util.Set<K> |
keys()
Get all keys associated to cached values
|
java.util.Set<K> |
keySet() |
V |
put(K key,
V value)
Associates the specified value with the specified key in the cache.
|
void |
putAll(java.util.Map<? extends K,? extends V> m) |
V |
remove(java.lang.Object key)
Remove the cached value by the key
|
int |
size()
Get the size of the cache
|
java.util.Collection<V> |
values()
Get all cached values
|
public UnlimitedConcurrentCache()
public UnlimitedConcurrentCache(int initialCapacity)
initialCapacity
- the initial capacitypublic V remove(java.lang.Object key)
public java.util.Map<K,V> clearAll()
clearAll
in interface EvictableCache<K,V>
public void clear()
clear
in interface java.util.Map<K,V>
clearAll()
public java.util.Collection<V> values()
public java.util.Set<K> keys()
keys
in interface EvictableCache<K,V>
public boolean containsKey(java.lang.Object key)
containsKey
in interface java.util.Map<K,V>
containsKey
in interface EvictableCache<K,V>
key
- key whose presence in this cache is to be tested.public boolean containsValue(java.lang.Object value)
public int size()
public V put(K key, V value)
put
in interface java.util.Map<K,V>
put
in interface MemoizeCache<K,V>
key
- key with which the specified value is to be associatedvalue
- value to be associated with the specified keypublic V get(java.lang.Object key)
public V getAndPut(K key, MemoizeCache.ValueProvider<? super K,? extends V> valueProvider)
getAndPut
in interface MemoizeCache<K,V>
public void cleanUpNullReferences()
cleanUpNullReferences
in interface MemoizeCache<K,V>