mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2024-11-17 22:03:50 +00:00
skipStartInvalidate
This commit is contained in:
parent
eaa014cebd
commit
39135a4000
@ -11,6 +11,9 @@
|
|||||||
* `Fragment`: `1.6.0` -> `1.6.1`
|
* `Fragment`: `1.6.0` -> `1.6.1`
|
||||||
* `Repos`:
|
* `Repos`:
|
||||||
* Fixes In `KeyValueRepo.clear()` of almost all inheritors of `KeyValueRepo`
|
* Fixes In `KeyValueRepo.clear()` of almost all inheritors of `KeyValueRepo`
|
||||||
|
* `Cache`:
|
||||||
|
* All full caches got `skipStartInvalidate` property. By default, this property is `false` and fully caching repos
|
||||||
|
will be automatically invalidated on start of their work
|
||||||
|
|
||||||
## 0.19.7
|
## 0.19.7
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package dev.inmo.micro_utils.repos.cache.full
|
package dev.inmo.micro_utils.repos.cache.full
|
||||||
|
|
||||||
import dev.inmo.micro_utils.common.*
|
import dev.inmo.micro_utils.common.*
|
||||||
|
import dev.inmo.micro_utils.coroutines.launchSafelyWithoutExceptions
|
||||||
import dev.inmo.micro_utils.pagination.Pagination
|
import dev.inmo.micro_utils.pagination.Pagination
|
||||||
import dev.inmo.micro_utils.pagination.PaginationResult
|
import dev.inmo.micro_utils.pagination.PaginationResult
|
||||||
import dev.inmo.micro_utils.repos.*
|
import dev.inmo.micro_utils.repos.*
|
||||||
@ -84,6 +85,7 @@ open class FullCRUDCacheRepo<ObjectType, IdType, InputValueType>(
|
|||||||
override val parentRepo: CRUDRepo<ObjectType, IdType, InputValueType>,
|
override val parentRepo: CRUDRepo<ObjectType, IdType, InputValueType>,
|
||||||
kvCache: FullKVCache<IdType, ObjectType>,
|
kvCache: FullKVCache<IdType, ObjectType>,
|
||||||
scope: CoroutineScope = CoroutineScope(Dispatchers.Default),
|
scope: CoroutineScope = CoroutineScope(Dispatchers.Default),
|
||||||
|
skipStartInvalidate: Boolean = false,
|
||||||
idGetter: (ObjectType) -> IdType
|
idGetter: (ObjectType) -> IdType
|
||||||
) : FullReadCRUDCacheRepo<ObjectType, IdType>(
|
) : FullReadCRUDCacheRepo<ObjectType, IdType>(
|
||||||
parentRepo,
|
parentRepo,
|
||||||
@ -97,6 +99,12 @@ open class FullCRUDCacheRepo<ObjectType, IdType, InputValueType>(
|
|||||||
idGetter
|
idGetter
|
||||||
),
|
),
|
||||||
CRUDRepo<ObjectType, IdType, InputValueType> {
|
CRUDRepo<ObjectType, IdType, InputValueType> {
|
||||||
|
init {
|
||||||
|
if (!skipStartInvalidate) {
|
||||||
|
scope.launchSafelyWithoutExceptions { invalidate() }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override suspend fun invalidate() {
|
override suspend fun invalidate() {
|
||||||
actualizeAll()
|
actualizeAll()
|
||||||
}
|
}
|
||||||
@ -105,12 +113,14 @@ open class FullCRUDCacheRepo<ObjectType, IdType, InputValueType>(
|
|||||||
fun <ObjectType, IdType, InputType> CRUDRepo<ObjectType, IdType, InputType>.fullyCached(
|
fun <ObjectType, IdType, InputType> CRUDRepo<ObjectType, IdType, InputType>.fullyCached(
|
||||||
kvCache: FullKVCache<IdType, ObjectType> = FullKVCache(),
|
kvCache: FullKVCache<IdType, ObjectType> = FullKVCache(),
|
||||||
scope: CoroutineScope = CoroutineScope(Dispatchers.Default),
|
scope: CoroutineScope = CoroutineScope(Dispatchers.Default),
|
||||||
|
skipStartInvalidate: Boolean = false,
|
||||||
idGetter: (ObjectType) -> IdType
|
idGetter: (ObjectType) -> IdType
|
||||||
) = FullCRUDCacheRepo(this, kvCache, scope, idGetter)
|
) = FullCRUDCacheRepo(this, kvCache, scope, skipStartInvalidate, idGetter)
|
||||||
|
|
||||||
@Deprecated("Renamed", ReplaceWith("this.fullyCached(kvCache, scope, idGetter)", "dev.inmo.micro_utils.repos.cache.full.fullyCached"))
|
@Deprecated("Renamed", ReplaceWith("this.fullyCached(kvCache, scope, idGetter)", "dev.inmo.micro_utils.repos.cache.full.fullyCached"))
|
||||||
fun <ObjectType, IdType, InputType> CRUDRepo<ObjectType, IdType, InputType>.cached(
|
fun <ObjectType, IdType, InputType> CRUDRepo<ObjectType, IdType, InputType>.cached(
|
||||||
kvCache: FullKVCache<IdType, ObjectType>,
|
kvCache: FullKVCache<IdType, ObjectType>,
|
||||||
scope: CoroutineScope = CoroutineScope(Dispatchers.Default),
|
scope: CoroutineScope = CoroutineScope(Dispatchers.Default),
|
||||||
|
skipStartInvalidate: Boolean = false,
|
||||||
idGetter: (ObjectType) -> IdType
|
idGetter: (ObjectType) -> IdType
|
||||||
) = fullyCached(kvCache, scope, idGetter)
|
) = fullyCached(kvCache, scope, skipStartInvalidate, idGetter)
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package dev.inmo.micro_utils.repos.cache.full
|
package dev.inmo.micro_utils.repos.cache.full
|
||||||
|
|
||||||
import dev.inmo.micro_utils.common.*
|
import dev.inmo.micro_utils.common.*
|
||||||
|
import dev.inmo.micro_utils.coroutines.launchSafelyWithoutExceptions
|
||||||
import dev.inmo.micro_utils.pagination.Pagination
|
import dev.inmo.micro_utils.pagination.Pagination
|
||||||
import dev.inmo.micro_utils.pagination.PaginationResult
|
import dev.inmo.micro_utils.pagination.PaginationResult
|
||||||
import dev.inmo.micro_utils.repos.*
|
import dev.inmo.micro_utils.repos.*
|
||||||
@ -106,10 +107,20 @@ fun <Key, Value> WriteKeyValueRepo<Key, Value>.caching(
|
|||||||
open class FullKeyValueCacheRepo<Key,Value>(
|
open class FullKeyValueCacheRepo<Key,Value>(
|
||||||
protected open val parentRepo: KeyValueRepo<Key, Value>,
|
protected open val parentRepo: KeyValueRepo<Key, Value>,
|
||||||
kvCache: FullKVCache<Key, Value>,
|
kvCache: FullKVCache<Key, Value>,
|
||||||
scope: CoroutineScope = CoroutineScope(Dispatchers.Default)
|
scope: CoroutineScope = CoroutineScope(Dispatchers.Default),
|
||||||
|
skipStartInvalidate: Boolean = false
|
||||||
) : FullWriteKeyValueCacheRepo<Key,Value>(parentRepo, kvCache, scope),
|
) : FullWriteKeyValueCacheRepo<Key,Value>(parentRepo, kvCache, scope),
|
||||||
KeyValueRepo<Key,Value>,
|
KeyValueRepo<Key,Value>,
|
||||||
ReadKeyValueRepo<Key, Value> by FullReadKeyValueCacheRepo(parentRepo, kvCache) {
|
ReadKeyValueRepo<Key, Value> by FullReadKeyValueCacheRepo(
|
||||||
|
parentRepo,
|
||||||
|
kvCache
|
||||||
|
) {
|
||||||
|
init {
|
||||||
|
if (!skipStartInvalidate) {
|
||||||
|
scope.launchSafelyWithoutExceptions { invalidate() }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override suspend fun unsetWithValues(toUnset: List<Value>) = parentRepo.unsetWithValues(toUnset)
|
override suspend fun unsetWithValues(toUnset: List<Value>) = parentRepo.unsetWithValues(toUnset)
|
||||||
|
|
||||||
override suspend fun invalidate() {
|
override suspend fun invalidate() {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package dev.inmo.micro_utils.repos.cache.full
|
package dev.inmo.micro_utils.repos.cache.full
|
||||||
|
|
||||||
import dev.inmo.micro_utils.common.*
|
import dev.inmo.micro_utils.common.*
|
||||||
|
import dev.inmo.micro_utils.coroutines.launchSafelyWithoutExceptions
|
||||||
import dev.inmo.micro_utils.pagination.*
|
import dev.inmo.micro_utils.pagination.*
|
||||||
import dev.inmo.micro_utils.pagination.utils.*
|
import dev.inmo.micro_utils.pagination.utils.*
|
||||||
import dev.inmo.micro_utils.repos.*
|
import dev.inmo.micro_utils.repos.*
|
||||||
@ -142,10 +143,17 @@ fun <Key, Value> WriteKeyValuesRepo<Key, Value>.caching(
|
|||||||
open class FullKeyValuesCacheRepo<Key,Value>(
|
open class FullKeyValuesCacheRepo<Key,Value>(
|
||||||
protected open val parentRepo: KeyValuesRepo<Key, Value>,
|
protected open val parentRepo: KeyValuesRepo<Key, Value>,
|
||||||
kvCache: FullKVCache<Key, List<Value>>,
|
kvCache: FullKVCache<Key, List<Value>>,
|
||||||
scope: CoroutineScope = CoroutineScope(Dispatchers.Default)
|
scope: CoroutineScope = CoroutineScope(Dispatchers.Default),
|
||||||
|
skipStartInvalidate: Boolean = false
|
||||||
) : FullWriteKeyValuesCacheRepo<Key, Value>(parentRepo, kvCache, scope),
|
) : FullWriteKeyValuesCacheRepo<Key, Value>(parentRepo, kvCache, scope),
|
||||||
KeyValuesRepo<Key, Value>,
|
KeyValuesRepo<Key, Value>,
|
||||||
ReadKeyValuesRepo<Key, Value> by FullReadKeyValuesCacheRepo(parentRepo, kvCache) {
|
ReadKeyValuesRepo<Key, Value> by FullReadKeyValuesCacheRepo(parentRepo, kvCache) {
|
||||||
|
init {
|
||||||
|
if (!skipStartInvalidate) {
|
||||||
|
scope.launchSafelyWithoutExceptions { invalidate() }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override suspend fun clearWithValue(v: Value) {
|
override suspend fun clearWithValue(v: Value) {
|
||||||
doAllWithCurrentPaging {
|
doAllWithCurrentPaging {
|
||||||
keys(v, it).also {
|
keys(v, it).also {
|
||||||
|
Loading…
Reference in New Issue
Block a user