MicroUtils/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/StandartKeyValueRepo.kt

23 lines
852 B
Kotlin
Raw Normal View History

2020-09-20 02:17:11 +00:00
package dev.inmo.micro_utils.repos
import dev.inmo.micro_utils.pagination.Pagination
import dev.inmo.micro_utils.pagination.PaginationResult
2020-09-21 00:23:13 +00:00
import kotlinx.coroutines.flow.Flow
2020-09-20 02:17:11 +00:00
interface StandardReadKeyValueRepo<Key, Value> : Repo {
suspend fun get(k: Key): Value?
suspend fun values(pagination: Pagination, reversed: Boolean): PaginationResult<Value>
suspend fun keys(pagination: Pagination, reversed: Boolean): PaginationResult<Key>
suspend fun contains(key: Key): Boolean
suspend fun count(): Long
}
interface StandardWriteKeyValueRepo<Key, Value> : Repo {
val onNewValue: Flow<Pair<Key, Value>>
val onValueRemoved: Flow<Key>
suspend fun set(k: Key, v: Value)
suspend fun unset(k: Key)
}
2020-09-26 16:02:12 +00:00
interface StandardKeyValueRepo<Key, Value> : StandardReadKeyValueRepo<Key, Value>, StandardWriteKeyValueRepo<Key, Value>