When the cache is full or an entry is stale, something must be removed — that’s eviction. Common strategies: TTL (time-to-live): remove after a fixed time; LRU (least recently used): remove the item that hasn’t been used for the longest time.
| Strategy | When evict | Use case |
|---|---|---|
| TTL | After fixed duration | Stale-safe data (e.g. 5 min for profile) |
| LRU | When full; drop least recently used | Bounded memory; keep “hot” data |
| LFU | When full; drop least frequently used | Keep most popular items |
| FIFO | When full; drop oldest inserted | Simple, no access tracking |
Combine TTL (so data doesn’t stay forever wrong) with LRU (so under memory pressure you drop the coldest entries). Many caches (e.g. Redis) support both.