mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2024-11-20 07:13:50 +00:00
start 0.12.11 and add values in key value cache repo
This commit is contained in:
parent
48e08fcc69
commit
44317d1519
@ -1,5 +1,11 @@
|
||||
# Changelog
|
||||
|
||||
## 0.12.11
|
||||
|
||||
* `Repos`:
|
||||
* `Cache`:
|
||||
* Override `KeyValue` cache method `values`
|
||||
|
||||
## 0.12.10
|
||||
|
||||
* `Repos`:
|
||||
|
@ -14,5 +14,5 @@ crypto_js_version=4.1.1
|
||||
# Project data
|
||||
|
||||
group=dev.inmo
|
||||
version=0.12.10
|
||||
android_code_version=149
|
||||
version=0.12.11
|
||||
android_code_version=150
|
||||
|
@ -1,7 +1,6 @@
|
||||
package dev.inmo.micro_utils.repos.cache
|
||||
|
||||
import dev.inmo.micro_utils.pagination.Pagination
|
||||
import dev.inmo.micro_utils.pagination.PaginationResult
|
||||
import dev.inmo.micro_utils.pagination.*
|
||||
import dev.inmo.micro_utils.repos.*
|
||||
import dev.inmo.micro_utils.repos.cache.cache.KVCache
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
@ -14,6 +13,16 @@ open class ReadKeyValueCacheRepo<Key,Value>(
|
||||
) : ReadKeyValueRepo<Key,Value> by parentRepo, CacheRepo {
|
||||
override suspend fun get(k: Key): Value? = kvCache.get(k) ?: parentRepo.get(k) ?.also { kvCache.set(k, it) }
|
||||
override suspend fun contains(key: Key): Boolean = kvCache.contains(key) || parentRepo.contains(key)
|
||||
|
||||
override suspend fun values(pagination: Pagination, reversed: Boolean): PaginationResult<Value> {
|
||||
return keys(pagination, reversed).let {
|
||||
it.changeResultsUnchecked(
|
||||
it.results.mapNotNull {
|
||||
get(it)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun <Key, Value> ReadKeyValueRepo<Key, Value>.cached(
|
||||
|
Loading…
Reference in New Issue
Block a user