Skip to content

Caching

Where caches sit, cache-aside reads and writes, how caches learn of change, and what goes wrong under load.

4 lessons

Where and how to cache

  1. 1Cache layers and where a cache sitsWhere a copy lives decides who shares it, how stale it can get, and who can delete it.
  2. 2Cache-aside and the read and write pathsThe database is the truth; the cache is whatever was written to it last. Delete after the commit, and the next read restores the truth.
  3. 3How caches learn of changeA cache learns of change only through a path you build. Cover every writer, and keep a TTL for when a path fails.

Caches under load

  1. 4Hot keys, big keys, cache penetration, and measuring a cacheA hot key stays on one shard: serve it from each pod for seconds, and judge a cache by what still reaches the origin.