Thuta Learning
Redis
AdvancedData & Databasesbeginner

Maxmemory and Eviction Policies

What you'll walk away with

  • Explain the core ideas behind Maxmemory and Eviction Policies
  • Run the sample Redis command or code and verify its output
  • Apply the technique correctly to the Tutorial Platform and production scenarios

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

shell
CONFIG GET maxmemory
CONFIG GET maxmemory-policy
CONFIG SET maxmemory 2gb
CONFIG SET maxmemory-policy allkeys-lfu
INFO stats
INFO memory
You should see
You 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 EvictionRedis

Easy traps

  • A runtime CONFIG SET may disappear after restart unless configuration management is updated too.
  • Validate sample commands on a local or test instance with recoverable data before applying them to production Redis.

Exercise

Recommend and justify policies for a pure cache, session store, and mixed workload.

You'll know it worked when: You can verify the configured ceiling, policy, and eviction counters.

Maxmemory and Eviction Policies | Thuta Learning