|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.camunda.commons.utils.cache.ConcurrentLruCache<K,V>
K - the type of keysV - the type of mapped valuespublic class ConcurrentLruCache<K,V>
A thread-safe LRU 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 | |
|---|---|
ConcurrentLruCache(int capacity)
Creates the cache with a fixed capacity. |
|
| Method Summary | |
|---|---|
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()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ConcurrentLruCache(int capacity)
capacity - max number of cache entries
IllegalArgumentException - if capacity is negative| Method Detail |
|---|
public V get(K key)
Cache
get in interface Cache<K,V>key - the key whose associated value is to be returned
null, if it does not exist.
public void put(K key,
V value)
Cache
put in interface Cache<K,V>key - key with which the specified value is to be associatedvalue - value to be associated with the specified keypublic void remove(K key)
Cache
remove in interface Cache<K,V>key - key with which the specified value is to be associated.public void clear()
Cache
clear in interface Cache<K,V>public boolean isEmpty()
Cachetrue if this cache contains no key-value mappings.
isEmpty in interface Cache<K,V>public Set<K> keySet()
Cache
keySet in interface Cache<K,V>public int size()
size in interface Cache<K,V>protected void removeAll(K key)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||