VISUAL REFERENCE

Caching Strategies Visual Map

Master caching patterns, writing strategies, and eviction policies for high-performance system design.

Cache-Aside (Lazy Loading)

Read Strategy
AppCacheDBMiss -> Read DB -> Update

Application manages the cache. Reads from DB if cache miss, then populates cache. Data is loaded on demand.

Write-Through

Write Strategy
AppCacheDBWrite Cache & DB Together

Data is written to cache and DB simultaneously. Ensures strong consistency but higher write latency.

Write-Back (Write-Behind)

Write Strategy
AppCacheDBAsyncFast Write -> Async Sync

Data written to cache immediately. Updated to DB asynchronously later. Fast writes, risk of data loss.

TTL (Time To Live)

Expiration
Key: ValueAuto-Expire

Data expires after a set time period. Useful for data that changes frequently or shouldn't be stale.

LRU Eviction

Eviction
ABCNewOldEvict Least Recently Used

Least Recently Used. Discards the least recently used items first when the cache is full.

Refresh-Ahead

Optimization
DataAuto-Refresh

Cache automatically refreshes recently accessed keys before they expire to prevent latency spikes.