@ThreadSafe public final class UnlimitedConcurrentCache<K, V> extends Object implements EvictableCache, Serializable
A cache backed by a ConcurrentHashMap
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(Map<? extends K, ? extends V> m) Constructs a cache and initialize the cache with the specified map |
Type Params | Return Type | Name and description |
---|---|---|
|
public void |
cleanUpNullReferences() Replying on the ConcurrentHashMap thread-safe iteration implementation the method will remove all entries holding SoftReferences to gc-evicted objects. |
|
public Map<K, V> |
clearAll() Clear the cache |
|
public boolean |
containsKey(Object key) Determines if the cache contains an entry for the specified key. |
|
public boolean |
containsValue(Object value) |
|
public Set<Entry<K, V>> |
entrySet() |
|
public V |
get(Object key) Gets a value from the cache |
|
public V |
getAndPut(K key, ValueProvider<? super K, ? extends V> valueProvider) Try to get the value from cache. |
|
public boolean |
isEmpty() |
|
public Set<K> |
keySet() |
|
public Set<K> |
keys() Get all keys associated to cached values |
|
public V |
put(K key, V value) Associates the specified value with the specified key in the cache. |
|
public void |
putAll(Map<? extends K, ? extends V> m) |
|
public V |
remove(Object key) Remove the cached value by the key |
|
public int |
size() Get the size of the cache |
|
public Collection<V> |
values() Get all cached values |
Constructs a cache with unlimited size
Constructs a cache with unlimited size and set its initial capacity
initialCapacity
- the initial capacityConstructs a cache and initialize the cache with the specified map
m
- the map to initialize the cacheReplying on the ConcurrentHashMap thread-safe iteration implementation the method will remove all entries holding SoftReferences to gc-evicted objects.
Clear the cache
Determines if the cache contains an entry for the specified key.
key
- key whose presence in this cache is to be tested.Gets a value from the cache
key
- the key whose associated value is to be returnedTry to get the value from cache. If not found, create the value by MemoizeCache.ValueProvider and put it into the cache, at last return the value.
valueProvider
- provide the value if the associated value not foundAssociates the specified value with the specified key in the cache.
key
- key with which the specified value is to be associatedvalue
- value to be associated with the specified keyRemove the cached value by the key
Get the size of the cache
Get all cached values
Copyright © 2003-2022 The Apache Software Foundation. All rights reserved.