Caching
The same idea, everywhere. From CPU registers to CDNs.
The Universal Pattern
Caching is not a "technique" - it's a fundamental response to physics. Whenever there's a speed gap between two layers, a cache emerges. CPU registers to L1. RAM to disk. Server to database. Browser to origin. The pattern is always the same.
Caches Are Everywhere
The Journey
First, the universal principles. Then, see them applied at every layer of the stack.
The Caching Contract
Coming SoonWhat every cache must promise
A cache pretends to BE the slow thing, but faster. It bets you'll ask for the same thing again soon.
Eviction - The Hard Choice
Coming SoonWhat to forget when memory is full
LRU, LFU, FIFO, ARC - every policy is a bet about future access patterns. There is no perfect answer.
Invalidation - The Hardest Problem
Coming Soon"There are only two hard things in CS..."
TTL, write-through, event-based - how does the cache know its data is stale? The unavoidable consistency vs performance tradeoff.
CPU Caches
Coming SoonThe cache you never control (but must understand)
L1/L2/L3 are invisible to your code, but determine whether your code is 10x fast or 10x slow. Cache lines, spatial locality, and why sequential access wins.
The Page Cache
Coming SoonThe OS's gift you didn't know you were using
Every file read goes through the page cache. read() doesn't read from disk - it copies from RAM. The OS already caches your I/O.
Application Caches
Coming SoonWhen the OS cache isn't enough (RocksDB Block Cache)
Page cache stores compressed data. Every read = decompress. Application caches store the TRANSFORMED version - decompressed, parsed, computed.
Distributed Caches
Coming SoonWhen one machine's memory isn't enough (Redis, Memcached)
100 app servers each caching the same data = waste. Shared cache tier solves this, but now you fight the network.
CDNs and Edge Caches
Coming SoonCaching across the planet
Server in Virginia, user in Tokyo = 200ms (physics!). Copy the data to the edge. Same eviction/invalidation tradeoffs, global scale.
The Unifying Patterns
Coming SoonWhat every cache has in common
Latency tradeoff, consistency spectrum, capacity curves, cold start, observability. Once you understand these, you understand every cache.
Connections to Other Chapters
Page cache is the OS's file cache. Now you understand why fsync() matters.
Block cache stores decompressed SST blocks. Bloom filters avoid cache misses entirely.
Compaction changes files. How does block cache handle invalidation?