Configuring Eviction Policies

1. Understanding Eviction Policies

WhenTrigger
used_memory ≥ maxmemoryPolicy selects keys to remove before each write

2. Using NoEviction Policy

PolicyBehavior
noevictionReject writes with OOM error; reads still served

3. Using AllKeys-LRU Policy

PolicyBehavior
allkeys-lruEvict least-recently-used across all keys

4. Using Volatile-LRU Policy

PolicyBehavior
volatile-lruEvict LRU among keys with TTL

5. Using AllKeys-LFU Policy

PolicyBehavior
allkeys-lfuEvict least-frequently-used (counter with decay)

6. Using Volatile-LFU Policy

PolicyBehavior
volatile-lfuLFU restricted to keys with TTL

7. Using AllKeys-Random Policy

PolicyBehavior
allkeys-randomEvict random key (cheap, no metadata)

8. Using Volatile-Random Policy

PolicyBehavior
volatile-randomRandom key among those with TTL

9. Using Volatile-TTL Policy

PolicyBehavior
volatile-ttlEvict key with smallest remaining TTL

10. Configuring LFU Parameters

DirectiveDescription
lfu-log-factor 10Higher = slower counter growth
lfu-decay-time 1Minutes per counter decrement

11. Monitoring Eviction Statistics

SourceField
INFO statsevicted_keys, evicted_clients
OBJECT FREQ keyLFU counter (requires LFU policy)
OBJECT IDLETIME keySeconds since last access (requires LRU)