redis no eviction mode, when will command be rejec...
创建于:2026年5月16日
使用 GPT-5.5 Thinking 回答 Chat01
创建于:2026年5月16日
使用 GPT-5.5 Thinking 回答 Chat01
redis no eviction mode, when will command be reject with oom error? will it accept one command that goes out of memory and reject anything else?
Yes — with maxmemory-policy noeviction, Redis will start returning OOM errors once used_memory is above the configured maxmemory, but it does not perfectly prevent a single accepted command from pushing memory over the limit.
Redis checks memory when a client runs a command that adds data; if memory is over the limit, it applies the configured policy. With noeviction, Redis does not evict keys and instead returns an error for commands that would cache/add new data; read-only commands still work normally. (Redis)
So the practical behavior is:
If Redis is currently below maxmemory:
A write command may be accepted. If that command allocates a lot of memory, it can push Redis over maxmemory. Redis docs explicitly note that a large command can temporarily exceed the limit by a large amount. (Redis)
After Redis is over maxmemory:
New commands marked denyoom are rejected with an OOM error. Redis command metadata defines denyoom as: command is rejected when server memory usage is too high. Examples include memory-growing writes like SET, MSET, LPUSH, ZADD, XADD, etc. (Redis)
Not everything is rejected:
Reads like GET, MGET, LRANGE, and admin/introspection commands generally continue. Memory-reducing commands such as DEL, UNLINK, LTRIM, or overwrites that reduce memory may still be allowed depending on command flags and behavior.
So your mental model is basically correct:
textused_memory < maxmemory -> Redis may accept a write -> that write may push memory above maxmemory used_memory > maxmemory + noeviction -> Redis rejects further memory-growing writes with OOM -> reads and some cleanup commands still work
The error is usually:
textOOM command not allowed when used memory > 'maxmemory'
The recovery is to delete/expire data, increase maxmemory, or change the eviction policy if Redis is acting as a cache rather than a durable data store.