Cache patterns, eviction, invalidation, distributed caching, HTTP caching, CDN, Redis, and common gotchas.
Preview — first 3 of 112 cards
Cache-aside (lazy loading)
App checks cache; on miss reads DB, writes cache, returns. Simple and resilient, but first request is slow and cache can go stale.
val = cache.get(key)
if val is None:
val = db.query(key)
cache.set(key, val, ttl)
return val
Read-through
Cache itself loads from DB on miss via a loader. App only talks to cache. Cleaner code, but cache must support loaders.
cache = Cache(loader=db.query)
val = cache.get(key) # auto-loads on miss
Write-through
Write to cache and DB synchronously. Cache always fresh, but adds the cache write to the write path. Good for read-heavy, consistency-critical data.
cache.set(key, val)
db.write(key, val) # both before returning
109 more cards in this sheet
Unlock the System Design bundle — ₹399
One-time payment. Unlocks this sheet and 10 other sheets in the bundle, plus a typeset PDF of each.
Unlock the bundle
See all bundles
Or get all 76 sheets for ₹999 — one payment, every future sheet included.