Skip to content

CoCacheTwo-level coherent cache for the JVM

Local-memory reads, Redis-shared state, and a hard bound on how stale any copy can get. For Java and Kotlin on Spring Boot.

Instance AL2Instance BL2Instance CL2Redis · L1Sourceload onceinvalidate everywhere

A cache in a dozen lines ​

kotlin
@CoCache(ttl = 600)                                   // seconds
interface UserCache : Cache<String, User>

@Bean                                                 // the data source, matched by type
fun userLoader(repo: UserRepository) = CacheLoader<String, User> { id -> repo.findById(id) }

@EnableCoCache(caches = [UserCache::class])
@SpringBootApplication
class App

// anywhere
val user = userCache["42"]                            // L2 → Redis → loader
invalidator.invalidate(userCache, "42")               // after the commit, on every instance

Get started in five minutes →

Released under the Apache License 2.0.