Card 1 of 5
Where does the copy of product 8812 live?
The shop caches popular products to reduce database reads. A shared cache hit crosses the network. A local hit avoids that trip, but each process now holds a copy that can become stale.
Emma opens the kettle page. Where is the copy of product 8812? Emma's phone page service read copy cache copy of 8812 (where?) product DB slow, busy Cache-aside: the page service owns the miss and refill path. source read on a miss
Redis: shared server with optional tracked client copies page service 1 trip Redis server copy of 8812 local copy of 8812 "8812 changed, drop yours" Tracked copies: discard if invalidation delivery is lost.
Redis is a separate server, so each read is one trip.
- Redis can also tell the page service: keep your own copy of 8812, and I'll message you when it changes.
- That feature is called client-side caching.
- With it, most reads make no trip at all.
But Your client library has to support this feature, and not all of them do.
If the connection that carries the 'it changed' messages drops, throw away the whole local copy, because you can no longer trust it.
Remember: A local hit skips the network trip. But it adds one more copy that can go stale, and the application must decide how old it may be.