โ Redis learning pathRedis ยท Module 6 of 10
Caching patterns
Cache-aside is the most common way to put Redis in front of a database.
๐ Key ideas
- Cache-aside: read from Redis; on a miss, read the DB and store the result with an expiry.
- Write-through: write to the cache and DB together.
- Always set a TTL so stale data eventually disappears.
- Delete or update the cache key when the DB row changes.
- Watch the hit ratio: hits divided by all reads.
๐ก Real-life example: Like keeping today's menu on the counter: check the counter first, and only walk to the office file when it is missing.
Cache hitThe data was found in the cache
Cache missThe data had to come from the database
Cache-asideApp reads cache, fills it on a miss
InvalidationRemoving cached data that changed