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?
|
2020-10-02 13:13:04 +00:00
|
|
|
suspend fun values(pagination: Pagination, reversed: Boolean = false): PaginationResult<Value>
|
|
|
|
suspend fun keys(pagination: Pagination, reversed: Boolean = false): PaginationResult<Key>
|
2020-09-20 02:17:11 +00:00
|
|
|
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>
|