Confirm the policy
maxmemory is the ceiling and maxmemory-policy decides what happens at the ceiling. allkeys-lru evicts least recently used keys, volatile-lru only evicts keys with a TTL, noeviction returns errors.
For caching, allkeys-lru is typical. If you use Redis as a datastore, never choose an eviction policy that discards data.
Find what is consuming memory
Scan with --bigkeys and inspect individual entries with MEMORY USAGE. Hashes with hundreds of thousands of fields and multi-megabyte strings are the usual culprits.
Also count keys without TTL. Code that sets values without expiry only grows, and memory eventually runs out.
Fix the structure
Split big keys: a million-field hash should become several hashes split by business dimension, making reads and writes cheaper.
Give every cache key a sensible TTL with random jitter, so expiry does not happen simultaneously and cause a stampede.
FAQ
What causes OOM command not allowed?
Memory reached maxmemory with noeviction. Either scale, change policy, or remove data.
Can eviction delete important data?
allkeys policies can. Keep critical data in a separate instance, or use a non-evicting policy with proper capacity planning.
Memory jumped suddenly. How do I investigate?
Look for abnormal writes, newly created big keys, or client buffer growth (check omem in CLIENT LIST).
Related questions
Further reading
Sources & References
The following are public sources. Always check the latest requirements on the official authority or platform page.
