Part 4 · 1 chapters · ~8 min
Eviction and Memory
maxmemory and the eviction policies, approximate LRU and LFU, TTLs and expiry (lazy and active), memory overhead per key, fragmentation and activedefrag, INFO memory, separating cache and data instances, and sizing.
6
Eviction, expiry and fragmentation
code
CONFIG SET maxmemory 4gb CONFIG SET maxmemory-policy allkeys-lfu INFO memory # used_memory, used_memory_rss, mem_fragmentation_ratio (> 1.5: fragmentation) CONFIG SET activedefrag yes # expiry: keys expire lazily when touched, and an active cycle samples keys with TTLs each second
EVICTION POLICIES
what Redis removes when maxmemory is reached
swipe the figure sideways, or tap expand for full screen
1/4
noeviction
The default: when memory is full, writes fail with an OOM error. Right for queues and data stores, where silently dropping data is worse than failing.
writes fail when fullright for queues and state