Package org.apache.camel
Interface TimeoutMap<K,V>
- All Superinterfaces:
AutoCloseable
,Service
Represents a map of values which timeout after a period of inactivity.
-
Nested Class Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addListener
(TimeoutMap.Listener<K, V> listener) Assign the (singular)TimeoutMap.Listener
Looks up the value in the map by the given key.Adds the key value pair into the map such that some time after the given timeout the entry will be evictedputIfAbsent
(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.Removes the object with the given keyint
size()
Returns the size of the map
-
Method Details
-
get
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
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
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
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
Assign the (singular)TimeoutMap.Listener
- Parameters:
listener
- the new listener
-