Configure Redis maxmemory-policy for a cache workload: choose between allkeys-lru, allkeys-lfu, and volatile variants, and tune LFU parameters

domain: redis.io/docs/latest/develop/reference/eviction · 6 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. Set a maxmemory limit to cap Redis memory consumption: redis-cli CONFIG SET maxmemory 2gb
  2. For a pure cache (all keys are ephemeral) use allkeys-lru or allkeys-lfu: CONFIG SET maxmemory-policy allkeys-lfu — allkeys-lfu evicts the least frequently accessed keys, better for skewed access patterns
  3. For mixed workloads where some keys must never be evicted (no expiry set), use volatile-lru or volatile-lfu which only evict keys with an TTL set
  4. Tune LFU parameters for allkeys-lfu or volatile-lfu: CONFIG SET lfu-log-factor 10 (higher value = slower frequency counter increment, more granular differentiation) and CONFIG SET lfu-decay-time 1 (minutes before frequency counter decays)
  5. Verify the current policy: CONFIG GET maxmemory-policy
  6. Monitor eviction metrics: INFO stats | grep evicted_keys — a rising evicted_keys count confirms eviction is active; cross-check with keyspace hit/miss ratio via INFO keyspace

Known gotchas

Related routes

Configure Prefect 3 task result caching with cache_policy and cache_key_fn
data-engineering · 5 steps · unrated

Give your agent this knowledge — and 15,500+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans