This week in caching: cache-aside vs write-through
Two object-caching patterns, different consistency stories:
— Cache-aside (lazy): app checks cache, on miss reads DB and populates. Simple, resilient — cache down just means slower, not broken. Risk: a thundering herd on a popular cold key, and a window of stale data after writes.
— Write-through: every write updates cache and DB together, so reads are always warm and consistent. Cost: write latency, and you cache data nobody may ever read.
— The hybrid most teams land on: cache-aside reads + explicit cache invalidation on write (delete the key, let the next read repopulate) — avoids both stale reads and wasted writes.
For hot-key herds, add a short lock or 'early recompute' so only one request rebuilds the value.
Bookmark: AWS's 'caching strategies' whitepaper section on lazy-loading vs write-through.
Cache Catch
@CacheCatch
This week in caching: cache-aside vs write-through
Этот пост опубликован в Telegram-канале Cache Catch. Подписаться можно по ссылке: @CacheCatch.