Interface TimeoutMap<K,V>
- Type Parameters:
K- the key typeV- the value type
- All Superinterfaces:
AutoCloseable, Service
A map whose entries expire automatically after a configurable period of inactivity.
Entries are added via
put(Object, Object, long) with an individual timeout in milliseconds. A background
Service thread periodically scans the map and evicts entries whose timeout has elapsed, notifying any
registered TimeoutMap.Listener. This is used internally by components that need session or correlation state with
automatic cleanup, such as the aggregator's in-memory repository and the idempotent consumer.- See Also:
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionvoidaddListener(TimeoutMap.Listener<K, V> listener) Assign the (singular)TimeoutMap.Listener@Nullable VLooks up the value in the map by the given key.@Nullable VAdds the key value pair into the map such that some time after the given timeout the entry will be evicted@Nullable VputIfAbsent(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.@Nullable VRemoves the object with the given keyintsize()Returns the size of the map
-
Method Details
-
get
-
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
-
addListener
Assign the (singular)TimeoutMap.Listener- Parameters:
listener- the new listener
-