caching
Cache Aside (Lazy Loading)
Application checks cache first, loads from DB on miss, then populates cache
Cache Hits0
Cache Misses0
Hit Rate—%
Cache Size0
Try: user_1, user_2, user_3, user_4, user_5
App
idle
→1. check
Cache
0 keys
→2. on miss
Database
5 rows
// cache contents
empty
// database rows
user_1: Alice
user_2: Bob
user_3: Carol
user_4: Dave
user_5: Eve
// event log
No events yet.
// how it works
- App checks cache first (fast path)
- On HIT: return cached value immediately
- On MISS: fetch from DB → store in cache → return
- Invalidate button removes stale entries
- Cache warms up over time with usage
// trade-offs
- Most common caching pattern in production
- Only caches data that's actually requested
- First request always a miss (cold start)
- Stale data if DB updates without invalidation