Choose the right TTL, define an invalidation strategy, measure hit rate, and treat cache stampedes as a design problem, not an incident.
Using a cache without breaking correctness
Define the TTL before the cache
A cache without a TTL is a stale-data generator waiting for an incident.
Decide how to invalidate
TTL, write-through, write-behind, or explicit invalidation. Pick one; document it.
Measure hit rate
A cache with a 5% hit rate is an expensive way to slow down requests.
Guard against stampedes
When a popular key expires, N requests recompute it at once. Use locks, single-flight or jitter.