Caching
Cache-aside, invalidation, stampedes and the local-versus-distributed decision — including the cases where a cache adds a consistency problem and buys nothing.
A cache trades correctness-in-time for work avoided; everything else in this module is about controlling that trade.
Read the cache, miss, read the database, write the cache — and the four things that go wrong in those four steps.
The database changed. How does the cache find out? Four answers, each with a different failure when it does not.
A TTL is a staleness budget written as a number, plus the only invalidation mechanism that cannot fail.
One popular key expires, every in-flight request misses at the same instant, and all of them run the same expensive query at once.
In-process is faster and per-instance; shared is consistent and one more thing that can be down. The choice is about invalidation, not speed.
A cache buys you a consistency problem and an availability dependency. Sometimes it does not buy anything back.