public class ConcurrentLRUCache<K,V> extends Object implements Cache<K,V>, Accountable
Note that the implementation does not follow a true LRU (least-recently-used) eviction strategy. Instead it strives to remove least recently used items but when the initial cleanup does not remove enough items to reach the 'acceptableWaterMark' limit, it can remove more items forcefully regardless of access order.
| Modifier and Type | Class and Description |
|---|---|
static class |
ConcurrentLRUCache.CacheEntry<K,V> |
static interface |
ConcurrentLRUCache.EvictionListener<K,V> |
static class |
ConcurrentLRUCache.Stats |
| Constructor and Description |
|---|
ConcurrentLRUCache(int size,
int lowerWatermark) |
ConcurrentLRUCache(int upperWaterMark,
int lowerWaterMark,
int acceptableWatermark,
int initialSize,
boolean runCleanupThread,
boolean runNewThreadForCleanup,
ConcurrentLRUCache.EvictionListener<K,V> evictionListener) |
ConcurrentLRUCache(long ramLowerWatermark,
long ramUpperWatermark,
boolean runCleanupThread,
ConcurrentLRUCache.EvictionListener<K,V> evictionListener) |
| Modifier and Type | Method and Description |
|---|---|
void |
clear() |
void |
destroy() |
protected void |
finalize() |
V |
get(K key) |
Collection<Accountable> |
getChildResources() |
Map<K,V> |
getLatestAccessedItems(int n) |
Map<Object,ConcurrentLRUCache.CacheEntry<K,V>> |
getMap() |
Map<K,V> |
getOldestAccessedItems(int n)
Returns 'n' number of oldest accessed entries present in this cache.
|
ConcurrentLRUCache.Stats |
getStats() |
V |
put(K key,
V val) |
long |
ramBytesUsed() |
V |
remove(K key) |
void |
setAlive(boolean live) |
int |
size() |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcomputeIfAbsentpublic ConcurrentLRUCache(long ramLowerWatermark,
long ramUpperWatermark,
boolean runCleanupThread,
ConcurrentLRUCache.EvictionListener<K,V> evictionListener)
public ConcurrentLRUCache(int upperWaterMark,
int lowerWaterMark,
int acceptableWatermark,
int initialSize,
boolean runCleanupThread,
boolean runNewThreadForCleanup,
ConcurrentLRUCache.EvictionListener<K,V> evictionListener)
public ConcurrentLRUCache(int size,
int lowerWatermark)
public void setAlive(boolean live)
public Map<K,V> getOldestAccessedItems(int n)
n - the number of oldest items neededpublic int size()
public Map<Object,ConcurrentLRUCache.CacheEntry<K,V>> getMap()
public void destroy()
public ConcurrentLRUCache.Stats getStats()
protected void finalize()
throws Throwable
public long ramBytesUsed()
ramBytesUsed in interface Accountablepublic Collection<Accountable> getChildResources()
getChildResources in interface AccountableCopyright © 2000-2020 Apache Software Foundation. All Rights Reserved.