Cachinglrulfueviction policy

Eviction

Definition

Eviction is the cache discarding entries when it reaches its memory limit, according to a policy such as least recently used (LRU), least frequently used (LFU) or FIFO.

In practice

Eviction is about capacity, while expiry is about freshness. LRU works well for most access patterns; LFU keeps steadily popular keys and resists one-off scans that would flush an LRU cache.

A cache that evicts constantly is too small for its working set, and the hit ratio shows it. In Redis, the maxmemory-policy setting decides whether keys are evicted or writes fail once memory is full.

Example

A 2 GB Redis instance with allkeys-lru evicts the least recently read sessions first when a traffic spike fills it.