All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jvmMain.RaptorKeyValueStore.kt Maven / Gradle / Ivy

package io.fluidsonic.raptor.keyvaluestore

import kotlinx.coroutines.flow.*


public interface RaptorKeyValueStore {

	public suspend fun clear()
	public fun entries(): Flow>
	public fun keys(): Flow
	public fun values(): Flow
	public suspend fun get(key: Key): Value?
	public suspend fun remove(key: Key): Boolean
	public suspend fun set(key: Key, value: Value)
	public suspend fun setIfAbsent(key: Key, value: Value): Boolean
}


public suspend fun  RaptorKeyValueStore.setIfAbsentOrRemove(key: Key, value: Value?) {
	when (value) {
		null -> remove(key)
		else -> setIfAbsent(key, value)
	}
}


public suspend fun  RaptorKeyValueStore.setOrRemove(key: Key, value: Value?) {
	when (value) {
		null -> remove(key)
		else -> set(key, value)
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy