The Desi Architect
Notes / Building Blocks / Caching Strategies
Track 2 · Building Blocks

Caching Strategies

A cache is a bet that the same question will be asked again. This page covers where to put the cache, how reads and writes should flow through it, what really happens when a step fails, and how a good cache falls over on the busiest night of the year.

Guide20 min read
On this page
  1. The 8 PM cliff
  2. The simple version
  3. Reading: three ways to fill a cache
  4. Writing: what happens to the cache when data changes
  5. The invalidation race in cache-aside
  6. Expiry and eviction
  7. When the cache itself becomes the problem
  8. Code: cache-aside with single flight and a safe lock
  9. What a cache means for consistency
  10. Decision table
  11. Common traps
  12. Cross-questions