What's the difference between cache invalidation and eviction?
Invalidation is primarily about correctness — the cached value should no longer be considered valid because the underlying data changed or its freshness window expired.
Eviction is primarily about cache resource management — removing an entry to free space or according to a cache policy such as LRU or LFU. An entry can be valid but evicted, or stale but still physically present until it’s removed.
| Invalidation | Eviction | |
|---|---|---|
| Main concern | Correctness | Capacity |
| Why? | Data became stale | Cache needs space |
| Who usually triggers it? | Application/business event | Cache system |
| Does value have to be stale? | Usually yes | No |
| Example | Product price changed | Redis is full |
| Typical mechanism | Delete/update/version | LRU/LFU/TTL policy |