DataEntryCacheWithTTL

Extension of DataEntryCache which supports TTLs.

Functions

Link copied to clipboard
inline suspend fun <T : Any> DataEntryCache<T>.count(block: QueryBuilder<T>.() -> Unit = {}): Long

Returns the amount of values that match the block.

Link copied to clipboard
inline fun <T : Any> DataEntryCache<T>.find(block: QueryBuilder<T>.() -> Unit = {}): Query<T>

Creates a new Query configured with the block.

Link copied to clipboard
inline fun <T : Any> DataEntryCache<T>.flow(block: QueryBuilder<T>.() -> Unit = {}): Flow<T>

Executes a query with the block and returns the values as a Flow.

Link copied to clipboard
open suspend fun put(vararg items: VALUE)
open suspend fun put(items: Iterable<VALUE>)
open suspend fun put(items: Flow<VALUE>)

Inserts the new items into the cache. Inserting an entry with an id that is already present will cause the old value to be overwritten.

open suspend override fun put(item: VALUE)

Inserts a new item into the cache. Inserting an entry with an id that is already present will cause the old value to be overwritten.

open suspend fun put(vararg items: VALUE, ttl: Duration)
open suspend fun put(items: Iterable<VALUE>, ttl: Duration)
open suspend fun put(items: Flow<VALUE>, ttl: Duration)

Inserts new expiring items into the cache for ttl. Inserting an entry with an id that is already present will cause the old value to be overwritten.

abstract suspend fun put(item: VALUE, ttl: Duration?)

Inserts a new expiring item into the cache for ttl. Inserting an entry with an id that is already present will cause the old value to be overwritten.

open suspend fun put(item: VALUE, until: Instant, clock: Clock = Clock.System)

Inserts a new item into the cache until it expires. Inserting an entry with an id that is already present will cause the old value to be overwritten.

open suspend fun put(vararg items: VALUE, until: Instant, clock: Clock = Clock.System)
open suspend fun put(items: Iterable<VALUE>, until: Instant, clock: Clock = Clock.System)
open suspend fun put(items: Flow<VALUE>, until: Instant, clock: Clock = Clock.System)

Inserts new items into the cache until it expires. Inserting an entry with an id that is already present will cause the old value to be overwritten.

Link copied to clipboard
abstract fun query(): QueryBuilder<VALUE>

Creates a new QueryBuilder that operates on this cache.

Link copied to clipboard
inline fun <T : Any> DataEntryCache<T>.query(block: QueryBuilder<T>.() -> Unit = {}): Query<T>

Creates a new Query configured with the block.

Link copied to clipboard
inline suspend fun <T : Any> DataEntryCache<T>.remove(block: QueryBuilder<T>.() -> Unit = {})

Removes all the values that match the block.