@com.github.javaparser.ast.expr.MarkerAnnotationExprThreadSafe public final class UnlimitedConcurrentCache extends Object
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 |
---|---|---|
|
void |
cleanUpNullReferences() Replying on the ConcurrentHashMap thread-safe iteration implementation the method will remove all entries holding SoftReferences to gc-evicted objects. |
|
Map<K, V> |
clearAll() Clear the cache |
|
boolean |
containsKey(Object key) Determines if the cache contains an entry for the specified key. |
|
boolean |
containsValue(Object value) |
|
Set<Entry<K, V>> |
entrySet() |
|
V |
get(Object key) Gets a value from the cache |
|
V |
getAndPut(K key, ValueProvider<? super K, ? extends V> valueProvider) Try to get the value from cache. |
|
boolean |
isEmpty() |
|
Set<K> |
keySet() |
|
Set<K> |
keys() Get all keys associated to cached values |
|
V |
put(K key, V value) Associates the specified value with the specified key in the cache. |
|
void |
putAll(Map<? extends K, ? extends V> m) |
|
V |
remove(Object key) Remove the cached value by the key |
|
int |
size() Get the size of the cache |
|
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 foundGet all keys associated to cached values
Associates 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-2020 The Apache Software Foundation. All rights reserved.