Kvs

Core key-value storage interface.

Kvs is the primary contract for reading and writing typed key-value pairs. All read operations are suspending and safe to call from any coroutine context. Writes are batched through KvsEditor and flushed atomically via KvsEditor.commit.

Implementations are provided by the artifact-specific factory functions on Storage (e.g. Storage.inMemoryKvs, Storage.kvsLight, Storage.kvsOptimized).

See also

Types

Link copied to clipboard
interface KvsEditor

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

Functions

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

Returns true if an entry with the given key exists in the store.

Link copied to clipboard
abstract fun edit(): Kvs.KvsEditor

Returns a new KvsEditor for staging write operations.

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
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
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
suspend fun Kvs.getFloatAsResult(key: String, defValue: Float): Result<Float>
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
suspend fun Kvs.getIntAsResult(key: String, defValue: Int): Result<Int>
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
suspend fun Kvs.getLongAsResult(key: String, defValue: Long): Result<Long>
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
Link copied to clipboard
abstract fun getStringAsStream(key: String, defValue: String): Flow<String>

Returns a Flow of the String value stored under key.