SYSTEM DESIGN SKETCHBOOK / VISUAL GUIDE RECAP
Where a cache helps (and where it lies)
What to remember
- A cache hit protects the store; the speed-up is a bonus.
- On a miss the service reads the store and fills the cache, so a cold or expired hot key can send a burst of misses to the store.
- Any change to the source of truth leaves cached copies stale until they expire or are purged.
- The TTL is the worst-case staleness. Write first, then purge, and keep the TTL as the safety net.
- For answers that must never be served (a takedown), check a small list on every request rather than trusting every cache to be purged.
Redraw from memory (fold the page so the figure is hidden)
From memory, draw the read path for a short-link redirect with a cache. Then explain, on the same page, what happens when a cached redirect needs to change: once for an ordinary edit and once for an urgent takedown.
Check afterwards: Browser, redirect service, cache and alias store, with the cache checked first. · The miss path: read the store, fill the cache, answer. · A TTL written next to the cache and named as the worst-case staleness. · The edit order: write the store, then purge the cache. · A disabled list checked on every request, including cache hits. · A note on why the redirect is a 302, not a 301.
Apply it: Design a URL shortener (No. 01 in the question bank)