Storage, Redis & Caching
Cache aside
Explain how cache-aside reads and writes can return stale data after a database change, and how deleting the cached key after the commit fixes most cases.
What you will be able to do
- Delete the cached key after a database commit and confirm the next read misses.
- Decide which entities need a stronger write path than delete-on-write.
What is in the lesson
- A real situation where this goes wrong
- How it works, step by step
- A walkthrough with commands you can run
- How it fails in production, and how to tell
- Three quiz questions with explanations
Read this lessonFree. No account needed.
More in Storage, Redis & Caching
- Redis eviction policiesAdvanced · 4 min
Explain how Redis eviction policies choose what to remove at the memory cap, and why a single instance shared by cache and session data can lose the wrong keys.
- TTL and stampedesAdvanced · 4 min
Explain how TTLs cause cache stampedes when keys expire together, and use jitter and a short rebuild lock to keep the database from taking the spike.
- Write through cachingAdvanced · 4 min
Explain write-through caching, where each write updates the cache, and why a failed cache write after a database commit leaves the two stores disagreeing silently.
- Cache invalidationAdvanced · 4 min
Explain how cache invalidation works through deletes, versioned keys and TTLs, and why a fact cached under many keys needs a dependency index to clear all of them.
- Redis persistenceAdvanced · 4 min
Explain how RDB snapshots and AOF differ in loss window, fsync policy and restart behaviour, and choose a setting from the loss the business can accept.
- Redis replicationAdvanced · 4 min
Explain how asynchronous replication copies writes to replicas, and why WAIT and a replica count lower the loss risk without making a write durable across failover.