K - the type of keysV - the type of mapped valuespublic class ConcurrentLruCache<K,V> extends Object implements Cache<K,V>
Cache with a fixed capacity. If the cache reaches
the capacity, it discards the least recently used entry first.
*Note*: The consistency of the keys queue with the keys in the cache is not ensured! This means, the keys queue can contain duplicates of the same key and not all the keys of the queue are necessarily in the cache. However, all the keys of the cache are at least once contained in the keys queue.
| Constructor and Description |
|---|
ConcurrentLruCache(int capacity)
Creates the cache with a fixed capacity.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Clears the contents of the cache.
|
V |
get(K key)
Gets an entry from the cache.
|
boolean |
isEmpty()
Returns
true if this cache contains no key-value mappings. |
Set<K> |
keySet()
Returns a Set view of the keys contained in this cache.
|
void |
put(K key,
V value)
Associates the specified value with the specified key in the cache.
|
void |
remove(K key)
Removes an entry from the cache.
|
protected void |
removeAll(K key)
Removes all instances of the given key within the keys queue.
|
int |
size() |
public ConcurrentLruCache(int capacity)
capacity - max number of cache entriesIllegalArgumentException - if capacity is negativepublic void put(K key, V value)
Cachepublic void remove(K key)
Cachepublic void clear()
Cachepublic boolean isEmpty()
Cachetrue if this cache contains no key-value mappings.public Set<K> keySet()
Cachepublic int size()
protected void removeAll(K key)
Copyright © 2018 Camunda Services GmbH. All rights reserved.