K
- the type of keys maintained by this mapV
- the type of mapped valuespublic class NavigableMapEvictionQueue<K,V> extends Object implements EvictionQueue<K,V>
EvictionQueue
which uses a
ConcurrentNavigableMap
to store its entries. The
key in the map is the eviction time of the entry, and the value is the entry
itself.Constructor and Description |
---|
NavigableMapEvictionQueue()
Creates a navigable map eviction queue with a
ConcurrentSkipListMap . |
NavigableMapEvictionQueue(ConcurrentNavigableMap<Long,EvictibleEntry<K,V>> map)
Creates a navigable map eviction queue with the specified map.
|
Modifier and Type | Method and Description |
---|---|
boolean |
evictEntries()
Evicts all entries that have expired from their maps and removes them
from the queue.
|
long |
getNextEvictionTime()
Returns the next eviction time of all entries contained in the queue, or
0 if the queue is empty.
|
boolean |
hasEntries()
Returns true if this queue contains any entries.
|
void |
putEntry(EvictibleEntry<K,V> e)
Puts the specified evictible entry into the queue.
|
void |
removeEntry(EvictibleEntry<K,V> e)
Removes the specified evictible entry from the queue.
|
public NavigableMapEvictionQueue()
ConcurrentSkipListMap
.public NavigableMapEvictionQueue(ConcurrentNavigableMap<Long,EvictibleEntry<K,V>> map)
map
- the map to be usedNullPointerException
- if the map is null
public boolean hasEntries()
This implementation simply returns true if the map is non-empty and vice versa.
hasEntries
in interface EvictionQueue<K,V>
public long getNextEvictionTime()
This implementation simply returns the first key in the map if it is non-empty, or 0 otherwise.
getNextEvictionTime
in interface EvictionQueue<K,V>
public void putEntry(EvictibleEntry<K,V> e)
This implementation simply invokes the put method on the map.
putEntry
in interface EvictionQueue<K,V>
e
- the entry to be put into the queue.public void removeEntry(EvictibleEntry<K,V> e)
This implementation simply invokes the remove method on the map.
removeEntry
in interface EvictionQueue<K,V>
e
- the entry to be removed from the queue.public boolean evictEntries()
This implementation uses the headMap method on the map to find all entries that should be evicted, and then calls the evict method on each one of them and removes them from the map.
evictEntries
in interface EvictionQueue<K,V>
Copyright © 2012–2016. All rights reserved.