From 947bd7c2c48f8fe92bee67c4fed995ca0c916e22 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Mon, 6 Nov 2023 18:59:17 +0600 Subject: [PATCH] fix build --- posts/panel/src/jvmMain/kotlin/Plugin.kt | 9 +++------ posts/src/jvmMain/kotlin/cached/CachedPostsRepo.kt | 6 +++++- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/posts/panel/src/jvmMain/kotlin/Plugin.kt b/posts/panel/src/jvmMain/kotlin/Plugin.kt index 059f9d4..63b9ec8 100644 --- a/posts/panel/src/jvmMain/kotlin/Plugin.kt +++ b/posts/panel/src/jvmMain/kotlin/Plugin.kt @@ -4,14 +4,11 @@ import com.benasher44.uuid.uuid4 import dev.inmo.micro_utils.coroutines.runCatchingSafely import dev.inmo.micro_utils.coroutines.subscribeSafelyWithoutExceptions import dev.inmo.micro_utils.koin.getAllDistinct +import dev.inmo.micro_utils.repos.* import dev.inmo.micro_utils.repos.cache.cache.FullKVCache import dev.inmo.micro_utils.repos.cache.cached import dev.inmo.micro_utils.repos.cache.full.cached -import dev.inmo.micro_utils.repos.deleteById -import dev.inmo.micro_utils.repos.id -import dev.inmo.micro_utils.repos.set -import dev.inmo.micro_utils.repos.unset -import dev.inmo.micro_utils.repos.value +import dev.inmo.micro_utils.repos.cache.full.fullyCached import dev.inmo.plagubot.Plugin import dev.inmo.plaguposter.common.ChatConfig import dev.inmo.plaguposter.common.UnsuccessfulSymbol @@ -99,7 +96,7 @@ object Plugin : Plugin { val api = koin.get() val basePostsMessages = PostsMessages(koin.get(), koin.get()) val postsMessages = if (koin.useCache) { - basePostsMessages.cached(FullKVCache(), koin.get()) + basePostsMessages.fullyCached(MapKeyValueRepo(), koin.get()) } else { basePostsMessages } diff --git a/posts/src/jvmMain/kotlin/cached/CachedPostsRepo.kt b/posts/src/jvmMain/kotlin/cached/CachedPostsRepo.kt index a410201..bc23003 100644 --- a/posts/src/jvmMain/kotlin/cached/CachedPostsRepo.kt +++ b/posts/src/jvmMain/kotlin/cached/CachedPostsRepo.kt @@ -1,10 +1,13 @@ package dev.inmo.plaguposter.posts.cached +import dev.inmo.micro_utils.coroutines.SmartRWLocker import korlibs.time.DateTime import dev.inmo.micro_utils.pagination.FirstPagePagination import dev.inmo.micro_utils.pagination.firstPageWithOneElementPagination import dev.inmo.micro_utils.pagination.utils.doForAllWithNextPaging import dev.inmo.micro_utils.repos.CRUDRepo +import dev.inmo.micro_utils.repos.KeyValueRepo +import dev.inmo.micro_utils.repos.MapKeyValueRepo import dev.inmo.micro_utils.repos.cache.cache.FullKVCache import dev.inmo.micro_utils.repos.cache.full.FullCRUDCacheRepo import dev.inmo.plaguposter.posts.models.NewPost @@ -20,12 +23,13 @@ import kotlinx.coroutines.flow.Flow class CachedPostsRepo( private val parentRepo: PostsRepo, private val scope: CoroutineScope, - private val kvCache: FullKVCache = FullKVCache() + private val kvCache: KeyValueRepo = MapKeyValueRepo() ) : PostsRepo, CRUDRepo by FullCRUDCacheRepo( parentRepo, kvCache, scope, skipStartInvalidate = false, + locker = SmartRWLocker(), { it.id } ) { override val removedPostsFlow: Flow by parentRepo::removedPostsFlow