mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2024-12-23 00:57:15 +00:00
remove redundant id getter in keyvalues autocached repo
This commit is contained in:
parent
580d757be2
commit
442db122cf
@ -61,7 +61,7 @@ open class AutoRecacheReadKeyValueRepo<Id, RegisteredObject>(
|
||||
override suspend fun get(k: Id): RegisteredObject? = actionWrapper.wrap {
|
||||
originalRepo.get(k)
|
||||
}.getOrNull() ?.also {
|
||||
kvCache.set(idGetter(it), it)
|
||||
kvCache.set(k, it)
|
||||
} ?: kvCache.get(k)
|
||||
|
||||
override suspend fun values(
|
||||
|
@ -12,15 +12,13 @@ open class AutoRecacheKeyValuesRepo<Id, RegisteredObject>(
|
||||
scope: CoroutineScope,
|
||||
kvCache: FullKVCache<Id, List<RegisteredObject>> = FullKVCache(),
|
||||
recacheDelay: Long = 60.seconds.inWholeMilliseconds,
|
||||
actionWrapper: ActionWrapper = ActionWrapper.Direct,
|
||||
idGetter: (RegisteredObject) -> Id
|
||||
actionWrapper: ActionWrapper = ActionWrapper.Direct
|
||||
) : AutoRecacheReadKeyValuesRepo<Id, RegisteredObject> (
|
||||
originalRepo,
|
||||
scope,
|
||||
kvCache,
|
||||
recacheDelay,
|
||||
actionWrapper,
|
||||
idGetter
|
||||
actionWrapper
|
||||
),
|
||||
WriteKeyValuesRepo<Id, RegisteredObject> by AutoRecacheWriteKeyValuesRepo(originalRepo, scope, kvCache),
|
||||
KeyValuesRepo<Id, RegisteredObject> {
|
||||
@ -30,9 +28,8 @@ open class AutoRecacheKeyValuesRepo<Id, RegisteredObject>(
|
||||
scope: CoroutineScope,
|
||||
originalCallTimeoutMillis: Long,
|
||||
kvCache: FullKVCache<Id, List<RegisteredObject>> = FullKVCache(),
|
||||
recacheDelay: Long = 60.seconds.inWholeMilliseconds,
|
||||
idGetter: (RegisteredObject) -> Id
|
||||
) : this(originalRepo, scope, kvCache, recacheDelay, ActionWrapper.Timeouted(originalCallTimeoutMillis), idGetter)
|
||||
recacheDelay: Long = 60.seconds.inWholeMilliseconds
|
||||
) : this(originalRepo, scope, kvCache, recacheDelay, ActionWrapper.Timeouted(originalCallTimeoutMillis))
|
||||
|
||||
override suspend fun clearWithValue(v: RegisteredObject) {
|
||||
super.clearWithValue(v)
|
||||
|
@ -27,8 +27,7 @@ open class AutoRecacheReadKeyValuesRepo<Id, RegisteredObject>(
|
||||
protected val scope: CoroutineScope,
|
||||
protected val kvCache: FullKVCache<Id, List<RegisteredObject>> = FullKVCache(),
|
||||
protected val recacheDelay: Long = 60.seconds.inWholeMilliseconds,
|
||||
protected val actionWrapper: ActionWrapper = ActionWrapper.Direct,
|
||||
protected val idGetter: (RegisteredObject) -> Id
|
||||
protected val actionWrapper: ActionWrapper = ActionWrapper.Direct
|
||||
) : ReadKeyValuesRepo<Id, RegisteredObject>, FallbackCacheRepo {
|
||||
val autoUpdateJob = scope.launch {
|
||||
while (isActive) {
|
||||
@ -43,9 +42,8 @@ open class AutoRecacheReadKeyValuesRepo<Id, RegisteredObject>(
|
||||
scope: CoroutineScope,
|
||||
originalCallTimeoutMillis: Long,
|
||||
kvCache: FullKVCache<Id, List<RegisteredObject>> = FullKVCache(),
|
||||
recacheDelay: Long = 60.seconds.inWholeMilliseconds,
|
||||
idGetter: (RegisteredObject) -> Id
|
||||
) : this(originalRepo, scope, kvCache, recacheDelay, ActionWrapper.Timeouted(originalCallTimeoutMillis), idGetter)
|
||||
recacheDelay: Long = 60.seconds.inWholeMilliseconds
|
||||
) : this(originalRepo, scope, kvCache, recacheDelay, ActionWrapper.Timeouted(originalCallTimeoutMillis))
|
||||
|
||||
protected suspend fun actualizeAll(): Result<Unit> {
|
||||
return runCatchingSafely {
|
||||
|
Loading…
Reference in New Issue
Block a user