tuweni / org.apache.tuweni.concurrent / ExpiringMap / put

put

@Nullable fun put(key: K, value: V): V? (source) @Nullable fun put(key: K, value: V, expiry: Long): V? (source)

Associates the specified value with the specified key in this map, and expires the entry when the specified expiry time is reached. If the map previously contained a mapping for the key, the old value is replaced by the specified value.

Parameters

key - K: The key with which the specified value is to be associated.

value - V: The value to be associated with the specified key.

expiry - Long: The expiry time for the value, in milliseconds since the epoch.

Return
V?: The previous value associated with key, or null if there was no mapping for key.

@Nullable fun put(key: K, value: V, expiry: Long, @Nullable expiryListener: BiConsumer<K, V>?): V? (source)

Associates the specified value with the specified key in this map, and expires the entry when the specified expiry time is reached. If the map previously contained a mapping for the key, the old value is replaced by the specified value.

Parameters

key - K: The key with which the specified value is to be associated.

value - V: The value to be associated with the specified key.

expiry - Long: The expiry time for the value, in milliseconds since the epoch.

expiryListener - BiConsumer<K, V>?: A listener that will be invoked when the entry expires.

Return
V?: The previous value associated with key, or null if there was no mapping for key.