Package org.apache.el.util
Class ConcurrentCache<K,V>
- java.lang.Object
-
- org.apache.el.util.ConcurrentCache<K,V>
-
- Type Parameters:
K- the key typeV- the value type
public final class ConcurrentCache<K,V> extends java.lang.ObjectA thread-safe cache that uses an eden space backed by aConcurrentHashMapand a long-term space backed by aWeakHashMap. When the eden space reaches the configured size, its contents are promoted to the long-term space.
-
-
Constructor Summary
Constructors Constructor Description ConcurrentCache(int size)Creates a new cache with the specified eden space size.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Vget(K k)Retrieves a value from the cache.voidput(K k, V v)Stores a value in the cache.
-
-
-
Method Detail
-
get
public V get(K k)
Retrieves a value from the cache. If found in the long-term store, it is promoted to the eden space for faster subsequent access. As forput(Object, Object), if the eden space is full, its contents are first moved to the long-term store so that the eden space never grows beyond the configured size.- Parameters:
k- the key to look up- Returns:
- the cached value, or
nullif not found
-
-