KvsExtended

Extended key-value storage interface with Time-To-Live (TTL) support.

KvsExtended augments the base KVS contract with the ability to associate an expiry Duration with individual entries. Expired entries are swept by the background CleanupJob returned from cleanupJob.

This interface is experimental and guarded by ExperimentalKvsTtl. Opt in with @OptIn(ExperimentalKvsTtl::class) or the compiler flag -opt-in=com.santimattius.kvs.ExperimentalKvsTtl.

See also

Types

Link copied to clipboard

Builder for applying a batch of write operations with optional TTL to the store.

Functions

Link copied to clipboard
abstract fun cleanupJob(interval: Duration): CleanupJob

Returns a CleanupJob that, when started, periodically scans the store and removes entries whose TTL has elapsed.

Link copied to clipboard
abstract suspend operator fun contains(key: String): Boolean

Returns true if an entry with the given key exists and has not expired.

Link copied to clipboard

Returns a new KvsExtendedEditor for staging write operations with optional TTL.

Link copied to clipboard
abstract suspend fun getAll(): Map<String, Any>

Returns all key-value entries currently held in the store.

Link copied to clipboard
abstract fun getAllAsStream(): Flow<Map<String, Any>>

Returns a Flow that emits the full store snapshot on every change.

Link copied to clipboard
abstract suspend fun getBoolean(key: String, defValue: Boolean): Boolean

Reads the Boolean value stored under key, returning defValue if absent.

Link copied to clipboard
abstract fun getBooleanAsStream(key: String, defValue: Boolean): Flow<Boolean>

Returns a Flow of the Boolean value stored under key.

Link copied to clipboard
abstract suspend fun getFloat(key: String, defValue: Float): Float

Reads the Float value stored under key, returning defValue if absent.

Link copied to clipboard
abstract fun getFloatAsStream(key: String, defValue: Float): Flow<Float>

Returns a Flow of the Float value stored under key.

Link copied to clipboard
abstract suspend fun getInt(key: String, defValue: Int): Int

Reads the Int value stored under key, returning defValue if absent.

Link copied to clipboard
abstract fun getIntAsStream(key: String, defValue: Int): Flow<Int>

Returns a Flow of the Int value stored under key.

Link copied to clipboard
abstract suspend fun getLong(key: String, defValue: Long): Long

Reads the Long value stored under key, returning defValue if absent.

Link copied to clipboard
abstract fun getLongAsStream(key: String, defValue: Long): Flow<Long>

Returns a Flow of the Long value stored under key.

Link copied to clipboard
abstract suspend fun getString(key: String, defValue: String): String

Reads the String value stored under key, returning defValue if absent.

Link copied to clipboard
abstract fun getStringAsStream(key: String, defValue: String): Flow<String>

Returns a Flow of the String value stored under key.