public class LongConcurrentLRUMap<V> extends LongMap<V>
| Modifier and Type | Class and Description |
|---|---|
private static class |
LongConcurrentLRUMap.CacheEntry<V> |
private static class |
LongConcurrentLRUMap.PQueue<V> |
private static class |
LongConcurrentLRUMap.PriorityQueue<T>
A PriorityQueue maintains a partial ordering of its elements such that the
least element can always be found in constant time.
|
LongMap.LongMapIterator<V>| Modifier and Type | Field and Description |
|---|---|
protected int |
acceptableWaterMark |
protected java.util.concurrent.atomic.AtomicLong |
accessCounter |
protected java.util.concurrent.atomic.AtomicLong |
evictionCounter |
protected boolean |
isCleaning |
protected int |
lowerWaterMark |
protected LongConcurrentHashMap<LongConcurrentLRUMap.CacheEntry<V>> |
map |
protected java.util.concurrent.locks.ReentrantLock |
markAndSweepLock |
protected java.util.concurrent.atomic.AtomicLong |
missCounter |
protected long |
oldestEntry |
protected java.util.concurrent.atomic.AtomicLong |
putCounter |
protected java.util.concurrent.atomic.AtomicInteger |
size |
protected int |
upperWaterMark |
| Constructor and Description |
|---|
LongConcurrentLRUMap(int size,
int lowerWatermark) |
LongConcurrentLRUMap(int upperWaterMark,
int lowerWaterMark,
int acceptableWatermark,
int initialSize) |
| Modifier and Type | Method and Description |
|---|---|
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
|
private void |
evictEntry(long key) |
V |
get(long key)
Returns the value of the mapping with the specified key.
|
LongMap<LongConcurrentLRUMap.CacheEntry<V>> |
getMap() |
boolean |
isEmpty()
Returns whether this map is empty.
|
LongMap.LongMapIterator<V> |
longMapIterator() |
private void |
markAndSweep()
Removes items from the cache to bring the size down
to an acceptable value ('acceptableWaterMark').
|
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.
|
java.util.Iterator<V> |
valuesIterator() |
protected final LongConcurrentHashMap<LongConcurrentLRUMap.CacheEntry<V>> map
protected final int upperWaterMark
protected final int lowerWaterMark
protected final java.util.concurrent.locks.ReentrantLock markAndSweepLock
protected boolean isCleaning
protected final int acceptableWaterMark
protected long oldestEntry
protected final java.util.concurrent.atomic.AtomicLong accessCounter
protected final java.util.concurrent.atomic.AtomicLong putCounter
protected final java.util.concurrent.atomic.AtomicLong missCounter
protected final java.util.concurrent.atomic.AtomicLong evictionCounter
protected final java.util.concurrent.atomic.AtomicInteger size
public LongConcurrentLRUMap(int upperWaterMark,
int lowerWaterMark,
int acceptableWatermark,
int initialSize)
public LongConcurrentLRUMap(int size,
int lowerWatermark)
public V get(long key)
LongMappublic boolean isEmpty()
LongMapisEmpty in class LongMap<V>true if this map has no elements, false
otherwise.LongMap.size()public V remove(long key)
LongMappublic V put(long key, V val)
LongMapprivate void markAndSweep()
private void evictEntry(long key)
public int size()
LongMappublic java.util.Iterator<V> valuesIterator()
valuesIterator in class LongMap<V>public LongMap.LongMapIterator<V> longMapIterator()
longMapIterator in class LongMap<V>public void clear()
LongMapclear in class LongMap<V>LongMap.isEmpty(),
LongMap.size()public LongMap<LongConcurrentLRUMap.CacheEntry<V>> getMap()
protected void evictedEntry(long key,
V value)