K
- The key typeV
- The value typepublic class ExpiringMap<K,V> extends Object implements Map<K,V>
Modifier and Type | Class and Description |
---|---|
class |
ExpiringMap.Expirer
A Thread that monitors an
ExpiringMap and will remove
elements that have passed the threshold. |
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_EXPIRATION_INTERVAL
The default value, 1 second
|
static int |
DEFAULT_TIME_TO_LIVE
The default value, 60 seconds
|
Constructor and Description |
---|
ExpiringMap()
Creates a new instance of ExpiringMap using the default values
DEFAULT_TIME_TO_LIVE and DEFAULT_EXPIRATION_INTERVAL
|
ExpiringMap(int timeToLive)
Creates a new instance of ExpiringMap using the supplied
time-to-live value and the default value for DEFAULT_EXPIRATION_INTERVAL
|
ExpiringMap(int timeToLive,
int expirationInterval)
Creates a new instance of ExpiringMap using the supplied values and
a
ConcurrentHashMap for the internal data structure. |
Modifier and Type | Method and Description |
---|---|
void |
addExpirationListener(ExpirationListener<V> listener)
Adds a listener in the expiration listeners
|
void |
clear() |
boolean |
containsKey(Object key) |
boolean |
containsValue(Object value) |
Set<Map.Entry<K,V>> |
entrySet() |
boolean |
equals(Object obj) |
V |
get(Object key) |
int |
getExpirationInterval()
Get the interval in which an object will live in the map before it is removed.
|
ExpiringMap.Expirer |
getExpirer() |
int |
getTimeToLive() |
int |
hashCode() |
boolean |
isEmpty() |
Set<K> |
keySet() |
V |
put(K key,
V value) |
void |
putAll(Map<? extends K,? extends V> inMap) |
V |
remove(Object key) |
void |
removeExpirationListener(ExpirationListener<V> listener)
Removes a listener from the expiration listeners
|
void |
setExpirationInterval(int expirationInterval)
Set the interval in which an object will live in the map before it is removed.
|
void |
setTimeToLive(int timeToLive)
Update the value for the time-to-live
|
int |
size() |
Collection<V> |
values() |
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
public static final int DEFAULT_TIME_TO_LIVE
public static final int DEFAULT_EXPIRATION_INTERVAL
public ExpiringMap()
public ExpiringMap(int timeToLive)
timeToLive
- The time-to-live value (seconds)public ExpiringMap(int timeToLive, int expirationInterval)
ConcurrentHashMap
for the internal data structure.timeToLive
- The time-to-live value (seconds)expirationInterval
- The time between checks to see if a value should be removed (seconds)public boolean containsKey(Object key)
containsKey
in interface Map<K,V>
public boolean containsValue(Object value)
containsValue
in interface Map<K,V>
public int hashCode()
public boolean equals(Object obj)
public void addExpirationListener(ExpirationListener<V> listener)
listener
- The listener to addpublic void removeExpirationListener(ExpirationListener<V> listener)
listener
- The listener to removepublic ExpiringMap.Expirer getExpirer()
public int getExpirationInterval()
public int getTimeToLive()
public void setExpirationInterval(int expirationInterval)
expirationInterval
- The expiration time in secondspublic void setTimeToLive(int timeToLive)
timeToLive
- The time-to-live (seconds)Copyright © 2004–2018 Apache MINA Project. All rights reserved.