Writing · 02.05.26 · 1 min

Cache invalidation: pub/sub isn't always the answer

Key design, TTL, and invalidation strategy — three points that fail quietly in production.

Cache invalidation: pub/sub isn't always the answer

"Cache invalidation is hard" is true — the bigger mistake is picking a strategy before writing down read/write ratio and consistency tolerance. Product cards are 99% reads with few writes daily; aggressive cache and short TTL fit. Cart and stock reservation need tolerance near zero — a different strategy entirely.

Fan-out invalidation via pub/sub looks fast, but a missed message means stale data forever. Without retry and DLQ you can get silent corruption on a night deploy. I prefer versioned keys as an alternative: write path bumps product:123:v42 to v43, old keys expire via TTL. Same goal without pub/sub complexity.

Cache invalidation strategies Choose strategy from metrics, not slides: hit ratio, stale incidents, p99 DB load after a miss. "We moved to Redis, done" without measuring isn't enough.

Cache invalidation: pub/sub isn't always the answer — Aziz Osmanoğlu