SteelReed

Search

Search posts, questions…

Caching & RedisQuestion 5 / 24

Middle

How do read-through, write-through, write-back and write-around differ?

Short answer

Read-through: the cache loads from the DB itself on a miss. Write-through: write cache and DB synchronously. Write-back: write only the cache, the DB is updated in batches later. Write-around: write straight to the DB, skipping the cache.

yesnoalwaysrarelysometimes, the defaultVery heavy writes,can lose a little?Write-backRead right after write?Write-throughWrite-aroundCache-aside, delete key

3 points to say:

  1. Write-through writes both synchronously: the cache is always fresh but write latency is high; write-around skips the cache, so a read right after the write misses.
  2. Write-back batches writes (like/view counters, analytics) but can lose data if the cache dies before it flushes.
  3. With Redis the default is cache-aside; choose by read/write ratio and how much data loss you can tolerate.

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.