Series · 7 parts
Two Hard Things: caching bugs
There are only two hard things in computer science, and cache invalidation is the one that pages you at 3 AM. This series takes the bugs I have actually watched take production down, one per minute: the write that races the cache, the delete that is not enough, the hot key whose expiry stampedes the database, the TTLs that all expire on the same schedule, and the “not found” nobody thought to cache.
Each part names the failure, shows why it happens, and ends on the boring fix that works. Watch them in order: every part assumes the cache from the one before.
IntroYour request passes five caches
Part 1You added a cache. Now you have two databases.
Part 2Deleting the cache key is not enough
Part 3One cache key expired. Your database went down.
Part 4Your outage has a schedule
Part 5Your cache never caches "not found"
Part 6Your cache just showed someone else's account