Package org.apache.camel
Interface TimeoutMap<K,V>
-
- All Superinterfaces:
AutoCloseable,Service
public interface TimeoutMap<K,V> extends Service
Represents a map of values which timeout after a period of inactivity.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceTimeoutMap.Listener<K,V>
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidaddListener(TimeoutMap.Listener<K,V> listener)Assign the (singular)TimeoutMap.ListenerVget(K key)Looks up the value in the map by the given key.Vput(K key, V value, long timeoutMillis)Adds the key value pair into the map such that some time after the given timeout the entry will be evictedVputIfAbsent(K key, V value, long timeoutMillis)Adds the key value pair into the map if the specified key is not already associated with a value such that some time after the given timeout the entry will be evicted.Vremove(K key)Removes the object with the given keyintsize()Returns the size of the map
-
-
-
Method Detail
-
get
V get(K key)
Looks up the value in the map by the given key.- Parameters:
key- the key of the value to search for- Returns:
- the value for the given key or null if it is not present (or has timed out)
-
size
int size()
Returns the size of the map- Returns:
- the size
-
put
V put(K key, V value, long timeoutMillis)
Adds the key value pair into the map such that some time after the given timeout the entry will be evicted- Parameters:
key- the keyvalue- the valuetimeoutMillis- timeout in millis- Returns:
- the previous value associated with key, or null if there was no mapping for key.
-
putIfAbsent
V putIfAbsent(K key, V value, long timeoutMillis)
Adds the key value pair into the map if the specified key is not already associated with a value such that some time after the given timeout the entry will be evicted. Expiry time of an existing mapping is left unchanged.- Parameters:
key- the keyvalue- the valuetimeoutMillis- timeout in millis- Returns:
- the value associated with key, or null if there was no mapping for key.
-
remove
V remove(K key)
Removes the object with the given key- Parameters:
key- key for the object to remove- Returns:
- the value for the given key or null if it is not present (or has timed out)
-
addListener
void addListener(TimeoutMap.Listener<K,V> listener)
Assign the (singular)TimeoutMap.Listener- Parameters:
listener- the new listener
-
-