@Deprecated public class ConcurrentLRUCache<V> extends Object
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.
ADDED COMMENT: This class has been copied from the Apache Solr project (see license above). New method has been added "putIfAbsent" which has the same behaviour as normal CHM.putIfAbsent but cache maintenance operations are only done in context of a winner thread, in other words, whoever puts absent item to the map would run cache maintenance ops, everybody else would be just newly added item returned.
Modifier and Type | Class and Description |
---|---|
static interface |
ConcurrentLRUCache.EvictionListener<V>
Deprecated.
|
static class |
ConcurrentLRUCache.Stats
Deprecated.
|
Constructor and Description |
---|
ConcurrentLRUCache(int size,
int lowerWatermark)
Deprecated.
|
ConcurrentLRUCache(int upperWaterMark,
int lowerWaterMark,
int acceptableWatermark,
int initialSize,
boolean runCleanupThread,
boolean runNewThreadForCleanup,
ConcurrentLRUCache.EvictionListener<V> evictionListener)
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Deprecated.
|
boolean |
containsKey(Long key)
Deprecated.
|
void |
destroy()
Deprecated.
|
protected void |
finalize()
Deprecated.
|
V |
get(Long key)
Deprecated.
|
Map<Long,V> |
getLatestAccessedItems(int n)
Deprecated.
|
Map<Long,org.janusgraph.graphdb.util.ConcurrentLRUCache.CacheEntry<Long,V>> |
getMap()
Deprecated.
|
Map<Long,V> |
getOldestAccessedItems(int n)
Deprecated.
Returns 'n' number of oldest accessed entries present in this cache.
|
ConcurrentLRUCache.Stats |
getStats()
Deprecated.
|
V |
put(Long key,
V val)
Deprecated.
|
V |
putIfAbsent(Long key,
V val)
Deprecated.
|
V |
remove(Long key)
Deprecated.
|
void |
setAlive(boolean live)
Deprecated.
|
int |
size()
Deprecated.
|
public ConcurrentLRUCache(int upperWaterMark, int lowerWaterMark, int acceptableWatermark, int initialSize, boolean runCleanupThread, boolean runNewThreadForCleanup, ConcurrentLRUCache.EvictionListener<V> evictionListener)
public ConcurrentLRUCache(int size, int lowerWatermark)
public void setAlive(boolean live)
public boolean containsKey(Long key)
public Map<Long,V> getOldestAccessedItems(int n)
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.
n
- the number of oldest items neededpublic int size()
public void clear()
public Map<Long,org.janusgraph.graphdb.util.ConcurrentLRUCache.CacheEntry<Long,V>> getMap()
public void destroy()
public ConcurrentLRUCache.Stats getStats()
Copyright © 2012–2023. All rights reserved.