Skip to content
Bluetape4k docs1.11

Cache strategies and ecosystem paths

Latest stable Based on Bluetape4k release 1.11.0

StrategyMiss/write ownerSource-store call
Cache-asideCallerCaller reads and writes the source directly
Read-throughCacheLoader/MapLoaderA cache miss invokes the loader
Write-throughCacheWriter/MapWriterA cache write invokes the writer before success
Write-behindWriter queueThe source is updated asynchronously after the cache

RedissonNearCache.put() and memoizer RMap.putIfAbsent() update Redis cache state. Without a writer that calls the database, neither is persistence write-through.

suspend fun findProduct(id: String): Product {
products.get(id)?.let { return it }
return repository.findById(id).also { loaded ->
products.put(id, loaded)
}
}

The first request reads the database and fills the cache. Updates still need a documented commit-versus-invalidation order and a stale-window policy.

examples/redisson-demo uses MapLoader, MapWriter, and async variants for read-through, write-through, and write-behind. These examples call an actual repository and therefore differ from cache-aside.

Write-behind can reduce response latency but introduces crash, queue overflow, ordering, and retry risks. Verify durability before making it the only path to the source of truth.

The exposed-workshop cache chapter connects JdbcCacheRepository, EntityMapLoader, and EntityMapWriter. bluetape4k-workshop continues with service-level examples. Judge strategy names by the actual loader/writer path when examples differ.