K - - type of the keys.V - - type of the values.public class ExpireHashMap<K,V> extends Object
Note that replaced key-value associations are only collected once the original expiration time has elapsed.
| Constructor and Description |
|---|
ExpireHashMap()
Construct a new hash map where each entry may expire at a given time.
|
ExpireHashMap(com.google.common.base.Ticker ticker)
Construct a new hash map where each entry may expire at a given time.
|
| Modifier and Type | Method and Description |
|---|---|
Map<K,V> |
asMap()
Retrieve a view of this expire map as an ordinary map that does not support insertion.
|
void |
clear()
Clear all the entries in the current map.
|
void |
collect()
Clear all references to key-value pairs that have been removed or replaced before they were naturally evicted.
|
boolean |
containsKey(K key)
Determine if the given key is referring to an unexpired association in the map.
|
boolean |
containsValue(V value)
Determine if the given value is referring to an unexpired association in the map.
|
Set<Map.Entry<K,V>> |
entrySet()
Retrieve a view of all the entries in the set.
|
protected void |
evictExpired()
Evict any expired entries in the map.
|
V |
get(K key)
Retrieve the value associated with the given key, if it has not expired.
|
Set<K> |
keySet()
Retrieve a view of the keys in the current map.
|
V |
put(K key,
V value,
long expireDelay,
TimeUnit expireUnit)
Associate the given key with the given value, until the expire delay have elapsed.
|
V |
removeKey(K key)
Remove a key and its associated value from the map.
|
int |
size()
Retrieve the number of entries in the map.
|
String |
toString() |
Collection<V> |
values()
Retrieve a view of all the values in the current map.
|
public ExpireHashMap()
public ExpireHashMap(com.google.common.base.Ticker ticker)
ticker - - supplier of the current time.public V get(K key)
key - - the key.public V put(K key, V value, long expireDelay, TimeUnit expireUnit)
key - - the key.value - - the value.expireDelay - - the amount of time until this association expires. Must be greater than zero.expireUnit - - the unit of the expiration.public boolean containsKey(K key)
key - - the key.public boolean containsValue(V value)
value - - the value.public V removeKey(K key)
key - - the key to remove.public int size()
public Set<K> keySet()
public Collection<V> values()
public Set<Map.Entry<K,V>> entrySet()
public Map<K,V> asMap()
public void collect()
This operation requires a linear scan of the current entries in the map.
public void clear()
protected void evictExpired()
This is called automatically by any of the read or write operations.
Copyright © 2012–2017 Comphenix and dmulloy2. Licensed under the GNU GPL v2.