Build the mental model
At maxmemory, Redis evicts keys or rejects writes according to policy. allkeys-lru or allkeys-lfu suits caches; volatile policies select only expiring keys; noeviction rejects writes. Eviction is sample-based, and operating-system headroom is needed for replication and AOF buffers.
Connect it to a real scenario
Test allkeys-lfu on a dedicated catalog-cache instance and measure hit ratio, evicted_keys, and latency under load. Keep sessions on separate capacity and policy to avoid accidental eviction. Alert on eviction and miss rates as well as used_memory versus maxmemory.
Try the working example
CONFIG GET maxmemory
CONFIG GET maxmemory-policy
CONFIG SET maxmemory 2gb
CONFIG SET maxmemory-policy allkeys-lfu
INFO stats
INFO memoryYou can verify the configured ceiling, policy, and eviction counters.5-minute try-it
Recommend and justify policies for a pure cache, session store, and mixed workload.
One important caution
A runtime CONFIG SET may disappear after restart unless configuration management is updated too.
Redis — Key Eviction — Redis