Video in progress

You need to pick a cache technology for a new service: Redis, Memcached, Hazelcast, or just in-process Caffeine. What criteria do you decide by?

First I answer whether the data needs to be shared between pods: if not, Caffeine is the fastest and cheapest. If it needs to be shared, Memcached for plain key-value and multi-core scaling; Redis for data structures, persistence, Pub/Sub and a wide ecosystem; Hazelcast if you need embedded distributed computing inside the JVM.

📖 Answer

My decision tree goes roughly like this:

  1. Can each pod have its own copy of the data? Configuration, translations, a small catalog: yes. Caffeine: nanoseconds, no network, zero operational cost. The downside: every pod warms up on its own, invalidation is hard, it takes heap and affects GC.

  2. If it needs to be shared:

Redis Memcached Hazelcast
Data structures rich (hash, zset, stream...) strings only Map, Queue, and others
Threading model mostly single thread multi-threaded JVM threads
Persistence/replicas yes no yes (backup copies)
Atomic operations Lua, transactions CAS EntryProcessor
Placement separate server separate server embedded or client-server
Ecosystem very wide moderate JVM-oriented

Memcached is for a pure cache with a very large and uniform key-value load; it uses many cores in a single instance and its memory management (slabs) is predictable. But for things like locks, counters and queues you'll end up bringing in Redis anyway.

Hazelcast in embedded mode lives in the same JVM as the application: reads with no network (near cache), but the application's deploy turns into a cluster rebalance and heap/GC problems increase. It makes sense when you have a JVM-only stack and need distributed computing.

Redis is the default in most cases, because the organization already has it, teams know it, there are many managed services, and one technology covers cache, locks, rate limits and queues.

The criteria I add: what the organization already runs and who is on call; the license (it changed after Redis 7.4, and Redis 8 added an AGPL option again, and in response the Valkey fork appeared, which managed services often offer); expected volume and growth.

For many services, the final answer is: "Caffeine L1 + Redis (or Valkey) L2". Adding a new technology needs a concrete reason, because each one is on-call load.