tuweni / org.apache.tuweni.concurrent / ExpiringMap

ExpiringMap

class ExpiringMap<K : Any!, V : Any!> : MutableMap<K, V> (source)

A concurrent hash map that stores values along with an expiry. Values are stored in the map until their expiry is reached, after which they will no longer be available and will appear as if removed. The actual removal is done lazily whenever the map is accessed, or when the #purgeExpired() method is invoked.

Constructors

<init>

Construct an empty map.

ExpiringMap()

Properties

entries

val entries: MutableSet<MutableEntry<K, V>>

keys

val keys: MutableSet<K>

size

val size: Int

values

val values: MutableCollection<V>

Functions

clear

fun clear(): Unit

compute

fun compute(key: K, remappingFunction: BiFunction<in K, in V?, out V?>): V?

computeIfAbsent

fun computeIfAbsent(key: K, mappingFunction: Function<in K, out V>): V
fun computeIfAbsent(key: K, expiration: Long, mappingFunction: Function<in K, out V>!): V

computeIfPresent

fun computeIfPresent(key: K, remappingFunction: BiFunction<in K, in V, out V?>): V?

containsKey

fun containsKey(key: K): Boolean

containsValue

fun containsValue(value: V): Boolean

equals

fun equals(other: Any?): Boolean

forEach

fun forEach(action: BiConsumer<in K, in V>): Unit

get

fun get(key: K): V?

getOrDefault

fun getOrDefault(key: K, defaultValue: V): V

hashCode

fun hashCode(): Int

isEmpty

fun isEmpty(): Boolean

merge

fun merge(key: K, value: V, remappingFunction: BiFunction<in V, in V, out V?>): V?

purgeExpired

Force immediate expiration of any key/value pairs that have reached their expiry.

fun purgeExpired(): Long

put

fun put(key: K, value: V): V?

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.

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

putAll

fun putAll(from: Map<out K, V>): Unit

putIfAbsent

fun putIfAbsent(key: K, value: V): V?

If the specified key is not already associated with a value, associates the specified value with the specified key in this map, and expires the entry when the specified expiry time is reached.

fun putIfAbsent(key: K, value: V, expiry: Long): V?
fun putIfAbsent(key: K, value: V, expiry: Long, expiryListener: BiConsumer<K, V>?): V?

remove

fun remove(key: K): V?
fun remove(key: K, value: V): Boolean

replace

fun replace(key: K, value: V): V?
fun replace(key: K, oldValue: V, newValue: V): Boolean

replaceAll

fun replaceAll(function: BiFunction<in K, in V, out V>): Unit