Caching fundamentalseasy0-2 years

A team adds a Redis cache in front of a product lookup and is surprised the win is only partly about speed — what does a cache actually buy beyond raw latency, and why should every cached entry get a TTL even when the application also deletes the entry on every write?

Speed is real — a Redis GET measured at about 75 microseconds against a roughly 2.6 millisecond database query, around 35 times faster — but the other half of the win is that every cache hit is a database query that never happens at all, which matters most when the database could technically answer fast enough but not thousands of times a second. A TTL matters even with careful write-side invalidation because it's the upper bound on how long any bug, missed evict call, or race condition can serve wrong data — an application can always forget to invalidate on some code path, but it can't forget the TTL, because Redis enforces it regardless of what the application does or doesn't do correctly.

The lesson behind it →
More on Caching fundamentals