
How Redis Caching Works
13 views · Aug 2026
sandboxed iframe · 49.5s loop · 42 KB
Two ways to keep a fast copy of your data — one fills the cache on demand, the other on every write.
Posted Aug 15, 2026 · 0 views
Both patterns put a cache in front of the database. They differ in who fills it, and when.
Cache-aside (lazy loading): the application checks the cache first. On a miss it reads the database and writes the value back. Writes go straight to the database and invalidate the cached copy, so the next read takes an L-shaped detour to refill it. Misses are easy to reason about, but a burst of concurrent misses on a hot key hits the database at once, and a failed invalidation serves a stale value until it expires.
Write-through: the write goes through the cache, which updates the database synchronously and does not return until both are done. The cache is never stale and reads after a write always hit — paid for on every single write, including data nobody will ever read.
The animation runs the same read-after-write under both: the detour appears in one and never in the other.

13 views · Aug 2026

3 views · Aug 2026

4 views · Aug 2026

1 view · Aug 2026

4 views · Aug 2026