All topicsTopic 09 / 24
Beginner 1 minute
Caching
A cache stores a reusable copy of data so future requests can avoid slower work. It can reduce database load and improve response time, but cached data can become stale and must eventually expire or be invalidated. Decide what is safe to cache, how long it can live, and what happens on a miss before adding one.
Key idea
Cache hits are fast; cache misses follow the normal path and refill the cache.
See it in one picture
Follow the arrowsApplication
Cache
fast hitDatabase
miss, then refillReal-world example
A product page can check Redis for a popular item's details first. On a miss, the application reads the database, returns the item, and stores a short-lived copy for the next shopper.
Quick check