Cachingcachingredismemcached

Cache

Definition

A cache stores the results of expensive operations or copies of data from a slower source, serving repeated requests from fast memory instead.

In practice

Caches exist at every level: CPU, browser, CDN, application memory, and shared stores such as Redis. A good cache cuts latency, protects the database and absorbs read spikes, as long as the data is read far more often than it changes.

Every cache trades freshness for speed. You must decide how entries get in (cache-aside, read-through), how they leave (TTL, eviction, invalidation) and what happens when the cache is empty or down, because a system sized only for cached traffic can collapse on a cold start.

Example

Product pages read from Redis in under 1 ms and fall back to a 30 ms database query on a miss, then store the result for 10 minutes.