Package org.camunda.commons.utils.cache
Class ConcurrentLruCache<K,V>
- java.lang.Object
-
- org.camunda.commons.utils.cache.ConcurrentLruCache<K,V>
-
- Type Parameters:
K- the type of keysV- the type of mapped values
- All Implemented Interfaces:
Cache<K,V>
public class ConcurrentLruCache<K,V> extends java.lang.Object implements Cache<K,V>
A thread-safe LRU org.camunda.commons.utils.cache.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 Summary
Constructors Constructor Description ConcurrentLruCache(int capacity)Creates the cache with a fixed capacity.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Clears the contents of the cache.Vget(K key)Gets an entry from the cache.booleanisEmpty()Returnstrueif this cache contains no key-value mappings.java.util.Set<K>keySet()Returns a Set view of the keys contained in this cache.voidput(K key, V value)Associates the specified value with the specified key in the cache.voidremove(K key)Removes an entry from the cache.protected voidremoveAll(K key)Removes all instances of the given key within the keys queue.intsize()
-
-
-
Method Detail
-
put
public void put(K key, V value)
Description copied from interface:CacheAssociates the specified value with the specified key in the cache.
-
remove
public void remove(K key)
Description copied from interface:CacheRemoves an entry from the cache.
-
clear
public void clear()
Description copied from interface:CacheClears the contents of the cache.
-
isEmpty
public boolean isEmpty()
Description copied from interface:CacheReturnstrueif this cache contains no key-value mappings.
-
keySet
public java.util.Set<K> keySet()
Description copied from interface:CacheReturns a Set view of the keys contained in this cache.
-
size
public int size()
-
removeAll
protected void removeAll(K key)
Removes all instances of the given key within the keys queue.
-
-