SteelReed

Search

Search posts, questions…

Caching & RedisQuestion 2 / 24

Junior

How does cache-aside work, and why does cache hit rate matter?

Short answer

Cache-aside: reads check the cache first; on a miss they read the DB and store the value with a TTL. Writes update the DB, then delete the key.

hitmissupdate DBRead requestIn the cache?Return at onceRead the DBSET key with TTLWrite requestDelete key

3 points to say:

  1. On write, update the DB first, then delete the key.
  2. The DB is the source of truth; if Redis dies the app still runs.
  3. A small hit-rate drop means much more DB load.

Keep reading the deep dive

Create a free account to read the full explanation and follow-up questions, mark questions as studied and review them on a schedule.