|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.mapdb.LongMap<V>
org.mapdb.LongConcurrentLRUMap<V>
public class LongConcurrentLRUMap<V>
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. MapDB note: reworked to implement LongMap. Original comes from: https://svn.apache.org/repos/asf/lucene/dev/trunk/solr/core/src/java/org/apache/solr/util/ConcurrentLRUCache.java
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class org.mapdb.LongMap |
|---|
LongMap.LongMapIterator<V> |
| Field Summary | |
|---|---|
protected int |
acceptableWaterMark
|
protected AtomicLong |
accessCounter
|
protected AtomicLong |
evictionCounter
|
protected boolean |
isCleaning
|
protected int |
lowerWaterMark
|
protected LongConcurrentHashMap<org.mapdb.LongConcurrentLRUMap.CacheEntry<V>> |
map
|
protected ReentrantLock |
markAndSweepLock
|
protected AtomicLong |
missCounter
|
protected long |
oldestEntry
|
protected AtomicLong |
putCounter
|
protected AtomicInteger |
size
|
protected int |
upperWaterMark
|
| Constructor Summary | |
|---|---|
LongConcurrentLRUMap(int size,
int lowerWatermark)
|
|
LongConcurrentLRUMap(int upperWaterMark,
int lowerWaterMark,
int acceptableWatermark,
int initialSize)
|
|
| Method Summary | |
|---|---|
void |
clear()
Removes all mappings from this hash map, leaving it empty. |
protected void |
evictedEntry(long key,
V value)
override this method to get notified about evicted entries |
V |
get(long key)
Returns the value of the mapping with the specified key. |
LongMap<org.mapdb.LongConcurrentLRUMap.CacheEntry<V>> |
getMap()
|
boolean |
isEmpty()
Returns whether this map is empty. |
LongMap.LongMapIterator<V> |
longMapIterator()
|
V |
put(long key,
V val)
Maps the specified key to the specified value. |
V |
remove(long key)
Removes the mapping from this map |
int |
size()
Returns the number of elements in this map. |
Iterator<V> |
valuesIterator()
|
| Methods inherited from class org.mapdb.LongMap |
|---|
toString |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected final LongConcurrentHashMap<org.mapdb.LongConcurrentLRUMap.CacheEntry<V>> map
protected final int upperWaterMark
protected final int lowerWaterMark
protected final ReentrantLock markAndSweepLock
protected boolean isCleaning
protected final int acceptableWaterMark
protected long oldestEntry
protected final AtomicLong accessCounter
protected final AtomicLong putCounter
protected final AtomicLong missCounter
protected final AtomicLong evictionCounter
protected final AtomicInteger size
| Constructor Detail |
|---|
public LongConcurrentLRUMap(int upperWaterMark,
int lowerWaterMark,
int acceptableWatermark,
int initialSize)
public LongConcurrentLRUMap(int size,
int lowerWatermark)
| Method Detail |
|---|
public V get(long key)
LongMap
get in class LongMap<V>key - the key.
null
if no mapping for the specified key is found.public boolean isEmpty()
LongMap
isEmpty in class LongMap<V>true if this map has no elements, false
otherwise.LongMap.size()public V remove(long key)
LongMap
remove in class LongMap<V>key - to remove
public V put(long key,
V val)
LongMap
put in class LongMap<V>key - the key.val - the value.
null if there was no such mapping.public int size()
LongMap
size in class LongMap<V>public Iterator<V> valuesIterator()
valuesIterator in class LongMap<V>public LongMap.LongMapIterator<V> longMapIterator()
longMapIterator in class LongMap<V>public void clear()
LongMap
clear in class LongMap<V>LongMap.isEmpty(),
LongMap.size()public LongMap<org.mapdb.LongConcurrentLRUMap.CacheEntry<V>> getMap()
protected void evictedEntry(long key,
V value)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||