Caffeine Store¶
In-process store backed by the Caffeine cache library. Suitable for single-node deployments where process-local caching is sufficient.
Dependency¶
<dependency>
<groupId>com.societegenerale.failover</groupId>
<artifactId>failover-store-caffeine</artifactId>
<version>3.0.0</version>
</dependency>
Configuration¶
No additional configuration is required. Caffeine uses the expireOn field from ReferentialPayload to set per-entry TTL at write time.
Behaviour¶
- Eviction: entries are evicted by Caffeine at their configured
expireOntimestamp. The cleanup scheduler still runs but has nothing to remove in most cases. - Memory: all entries live in the JVM heap. Size is bounded by the number of distinct failover keys in your application.
- Persistence: data is lost on JVM restart — the first post-restart calls are unprotected until upstream succeeds.
- Multi-node: each node has its own cache. There is no cluster synchronisation.
When to Use vs JDBC¶
| Scenario | Caffeine | JDBC |
|---|---|---|
| Single-node deployment | ✅ | ✅ |
| Multiple nodes / horizontal scale | ❌ | ✅ |
| Survive restarts | ❌ | ✅ |
| Zero external dependency | ✅ | Requires a DB |
| Low-latency reads | ✅ (in-process) | Depends on DB latency |
Next Steps¶
- JDBC Store — persistent, multi-node store
- Store Types — comparison of all store types