~learn.
0:00 / 1:17
W04 · Caching

Just add Redis. Then the sale ends and your cache never hears.

transcript

Slow system? Everyone knows the fix. Just add Redis. Then a sale ends. And your cache never hears about it.

The sale is over. The database goes back to 99 dollars. But the cache still shows the sale price. 79. The customer expects 79. The card is charged 99. Now they're angry. A support ticket. A refund. One stale key did that.

Or worse. Black Friday, midnight. 100,000 users waiting to refresh. The homepage cache expires. One second later, 100,000 requests hit your database. One second after that, it's on fire.

And feeds? A celebrity has 300 million followers. They post once. Push it to every follower's feed cache: 300 million writes. For one post.

So the real questions come first. When do you invalidate? Too early wastes it. Too late is stale. How do you survive a storm of misses? And sometimes the right answer: don't cache it at all.

Five days. Patterns, invalidation, herds, feeds, and a cache at every layer. Cache strategically, not reflexively. You'll never say just add Redis again.

Full breakdown in the lecture.