Cache-aside puts the caching logic in your application. Read-through and write-through move it into the cache layer itself, so the application talks to the cache as if it were the database and the cache handles loading from and writing to the backing store. The difference sounds subtle, but it changes who owns the logic, how consistent the cache stays, and where the complexity lives. Knowing all three patterns lets you pick the right consistency-versus-complexity tradeoff per use case.
This is part 10 of the Redis Masterclass, following cache-aside.
Read-through: the cache loads on a miss
In read-through, the application always reads from the cache, and the cache is responsible for fetching from the database on a miss. Where cache-aside has the application do the "load from DB and populate" step, read-through hides that behind the cache layer:
// application code is simple: just read from the cache
const user = await cache.get(`user:${id}`);
// the cache layer, on a mis
Discussion
Start the conversation
Your voice can be the first to spark an engaging conversation.