Package org.apache.myfaces.util.lang
Class ConcurrentLRUCache<K,V>
- java.lang.Object
- 
- org.apache.myfaces.util.lang.ConcurrentLRUCache<K,V>
 
- 
 public class ConcurrentLRUCache<K,V> extends Object A LRU cache implementation based upon ConcurrentHashMap and other techniques to reduce contention and synchronization overhead to utilize multiple CPU cores more effectively.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. See org.apache.solr.util.ConcurrentLRUCache- Since:
- solr 1.4
 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description static interfaceConcurrentLRUCache.EvictionListener<K,V>static classConcurrentLRUCache.Stats
 - 
Constructor SummaryConstructors Constructor Description ConcurrentLRUCache(int size, int lowerWatermark)ConcurrentLRUCache(int upperWaterMark, int lowerWaterMark, int acceptableWatermark, int initialSize, boolean runCleanupThread, boolean runNewThreadForCleanup, ConcurrentLRUCache.EvictionListener<K,V> evictionListener)
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()voiddestroy()protected voidfinalize()Vget(K key)Map<K,V>getLatestAccessedItems(int n)Map<Object,org.apache.myfaces.util.lang.ConcurrentLRUCache.CacheEntry<K,V>>getMap()Map<K,V>getOldestAccessedItems(int n)Returns 'n' number of oldest accessed entries present in this cache.ConcurrentLRUCache.StatsgetStats()Vput(K key, V val)Vremove(K key)voidsetAlive(boolean live)intsize()
 
- 
- 
- 
Constructor Detail- 
ConcurrentLRUCachepublic ConcurrentLRUCache(int upperWaterMark, int lowerWaterMark, int acceptableWatermark, int initialSize, boolean runCleanupThread, boolean runNewThreadForCleanup, ConcurrentLRUCache.EvictionListener<K,V> evictionListener)
 - 
ConcurrentLRUCachepublic ConcurrentLRUCache(int size, int lowerWatermark)
 
- 
 - 
Method Detail- 
setAlivepublic void setAlive(boolean live) 
 - 
getOldestAccessedItemspublic Map<K,V> getOldestAccessedItems(int n) Returns 'n' number of oldest accessed entries present in this cache. This uses a TreeSet to collect the 'n' oldest items ordered by ascending last access time and returns a LinkedHashMap containing 'n' or less than 'n' entries.- Parameters:
- n- the number of oldest items needed
- Returns:
- a LinkedHashMap containing 'n' or less than 'n' entries
 
 - 
sizepublic int size() 
 - 
clearpublic void clear() 
 - 
getMappublic Map<Object,org.apache.myfaces.util.lang.ConcurrentLRUCache.CacheEntry<K,V>> getMap() 
 - 
destroypublic void destroy() 
 - 
getStatspublic ConcurrentLRUCache.Stats getStats() 
 
- 
 
-