Skip to content
Bluetape4k docs1.11

Redisson JCache and suspend wrappers

Latest stable Based on Bluetape4k release 1.11.0

RedissonJCaching uses Redisson’s JCachingProvider to create standard javax.cache.Cache instances. RedissonSuspendJCache wraps the same cache with SuspendJCache. RedissonCaches exposes both choices through one factory.

val cache = RedissonCaches.suspendJCache<String, User>(
redisson = redissonClient,
cacheName = "users",
configuration = MutableConfiguration<String, User>().apply {
setTypes(String::class.java, User::class.java)
},
)
cache.put("u:1", User("u:1", "debop"))

Passing a RedissonClient keeps ownership in the application. A Config overload allows the provider to participate in client creation, so document manager and client shutdown separately.

RedissonJCaching.cacheManager is a lazy singleton. getOrCreate reuses an existing named cache. Do not assume a new configuration replaces the type, expiry, loader, or writer of an existing cache. Tests should use unique names and clean up their entries or wrappers.

Most CRUD methods call Redisson JCache *Async() methods and await() them. putAllFlow starts individual puts and waits for all of them. entries() iterates the cache directly, so a large scan is not automatically a cheap non-blocking stream. removeAll() explicitly runs the blocking provider call on Dispatchers.IO.

Redisson JCache has no getAndPutAsync() in this path. The 1.11.0 wrapper performs get followed by put, allowing another writer to interleave. Use an atomic RMap operation when strict read-modify-write semantics matter.

close() closes the wrapped JCache but does not delete stored entries. Use clear() or removeAll() for data removal. Ordinary close failures are logged; CancellationException is rethrown.