Configuring Eviction Policies
1. Understanding Eviction Policies
| When | Trigger |
|---|---|
| used_memory ≥ maxmemory | Policy selects keys to remove before each write |
2. Using NoEviction Policy
| Policy | Behavior |
|---|---|
noeviction | Reject writes with OOM error; reads still served |
3. Using AllKeys-LRU Policy
| Policy | Behavior |
|---|---|
allkeys-lru | Evict least-recently-used across all keys |
4. Using Volatile-LRU Policy
| Policy | Behavior |
|---|---|
volatile-lru | Evict LRU among keys with TTL |
5. Using AllKeys-LFU Policy
| Policy | Behavior |
|---|---|
allkeys-lfu | Evict least-frequently-used (counter with decay) |
6. Using Volatile-LFU Policy
| Policy | Behavior |
|---|---|
volatile-lfu | LFU restricted to keys with TTL |
7. Using AllKeys-Random Policy
| Policy | Behavior |
|---|---|
allkeys-random | Evict random key (cheap, no metadata) |
8. Using Volatile-Random Policy
| Policy | Behavior |
|---|---|
volatile-random | Random key among those with TTL |
9. Using Volatile-TTL Policy
| Policy | Behavior |
|---|---|
volatile-ttl | Evict key with smallest remaining TTL |
10. Configuring LFU Parameters
| Directive | Description |
|---|---|
lfu-log-factor 10 | Higher = slower counter growth |
lfu-decay-time 1 | Minutes per counter decrement |
11. Monitoring Eviction Statistics
| Source | Field |
|---|---|
INFO stats | evicted_keys, evicted_clients |
OBJECT FREQ key | LFU counter (requires LFU policy) |
OBJECT IDLETIME key | Seconds since last access (requires LRU) |