Skip to main content
PProfileMatch
← Path

Redis · Redis Caching: Cache-Aside, TTLs and Invalidation in Practice

0 XP
  1. 1 current stop: learning
  2. 2 upcoming
  3. 3 upcoming
  4. 4 upcoming
  5. 5 upcoming

Finish after stop 5

Stop 1 of 5 · Cinema box office, showtimes board

Trick to keep in mind+3 XP

On a write, delete the cache entry instead of patching it, and do it after saving to the database.

Redis is never told when the database changes, so the write path must act. Saving first and then deleting lets the next read rebuild from fresh data. Updating the cache directly is riskier, because two racing writers can leave the older value behind, and deleting before saving lets a reader refill the old copy in the gap.

Read it once, then a question tests whether the trick stuck.