[rdct, rd-necropolis] IJPL-198448: Reuse opened cache whenever possible

If the frontend is reopened without stopping the client, it will try to register the remote caches on the backend. However, if the backend has not been stopped, it will leave the caches opened, so reregistration will fail with the exception.

This commit introduces the reusing of the caches, which should fix the exception


(cherry picked from commit 52695f24db542428e46b9551e5fca976372d768d)

IJ-CR-171354

GitOrigin-RevId: 8240f3634de6d189b7f3d684e33f59f4372ea07e
This commit is contained in:
Sergei Kharitontcev-Beglov
2025-08-04 13:22:08 +02:00
committed by intellij-monorepo-bot
parent 4d2548e92f
commit 0423ebaf89

View File

@@ -34,16 +34,16 @@ private class RemoteManagedCacheManager(private val project: Project, private va
return storage[cacheId.name]!!
}
suspend fun create(cacheId: CacheId, buildParams: RemoteManagedCacheBuildParams): EntriesFlow {
val cache = ManagedCacheFactory.getInstance().createCache(
project,
remoteCacheLocation(),
cacheId.name,
MyKeyDescriptor(),
Externalizer(),
buildParams.serdeVersion,
coroutineScope
)
storage[cacheId.name] = cache
val cache = storage[cacheId.name]
?: ManagedCacheFactory.getInstance().createCache(
project,
remoteCacheLocation(),
cacheId.name,
MyKeyDescriptor(),
Externalizer(),
buildParams.serdeVersion,
coroutineScope
).also { storage[cacheId.name] = it }
return cache.entries()
}