Reference · Cheat sheet

TTL vs eviction

Time kills one key; memory pressure kills many. Print it, pin it.

From lesson 0003See also glossary

Two mechanisms, one outcome

TTL expiryEviction
TriggerTime — per keyMemory pressure — global
ScopeThe one key you markedWhatever the policy selects
Configured byEXPIRE / SET EXmaxmemory + maxmemory-policy
Meaning"This datum is stale""We're out of room"

TTL commands

How a TTL deletes

Eviction policies

Candidate setlrulfurandomttl
allkeys-* (any key)
volatile-* (only TTL'd keys)
Two production traps

Default is noeviction — a cache under memory pressure starts erroring, not evicting. Set allkeys-lru/allkeys-lfu.
volatile-* with no TTL'd keys = nothing to evict = behaves like noeviction.

Replica note

Only the primary expires keys; replicas wait for its synthesized DEL. A replica read can return a logically-expired value until then.

← lesson 0003 · Source: Redis Docs — Key eviction · expiration FAQ