SimpleBucketStateMapWithEviction

class SimpleBucketStateMapWithEviction(clock: Clock, stateMap: SimpleBucketStateMap = SimpleBucketStateMap(), ttlAfterLastAccess: Duration = 2.hours, expirationCheckInterval: Duration = 10.minutes, coroutineScope: CoroutineScope = CoroutineScope(Dispatchers.Default)) : BucketStateMap

A simple in-memory state map implementation that expires keys after a given time-to-live.

Parameters

clock

the clock to use to get the current time

stateMap

the state map to use to store the state

ttlAfterLastAccess

the time-to-live after the last access

expirationCheckInterval

the interval at which to check for expired keys

coroutineScope

the CoroutineScope to use to run the expiration check

Constructors

Link copied to clipboard
constructor(clock: Clock, stateMap: SimpleBucketStateMap = SimpleBucketStateMap(), ttlAfterLastAccess: Duration = 2.hours, expirationCheckInterval: Duration = 10.minutes, coroutineScope: CoroutineScope = CoroutineScope(Dispatchers.Default))

Functions

Link copied to clipboard

Returns the AtomicReference of the BucketState for the given key. If the key is not present in the map, it returns null.

Link copied to clipboard

Puts the value in the map if the key is not present. If the key is already present, it returns the AtomicReference of the BucketState for the given key. If the key is not present in the map, it returns null.