public class ConcurrentLRUCache<K,V> extends Object implements Cache<K,V>
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) |
Modifier and Type | Method and Description |
---|---|
void |
clear() |
void |
destroy() |
protected void |
finalize() |
V |
get(K key) |
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) |
V |
remove(K key) |
void |
setAlive(boolean live) |
int |
size() |
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()
Copyright © 2000-2016 Apache Software Foundation. All Rights Reserved.