Diagnose eviction, expiry and OOM errors
RedisMemoryCommand
INFO stats
# Fields to check: evicted_keys, expired_keys, expired_stale_perc, keyspace_hits, keyspace_misses, total_eviction_exceeded_time (7.0+)
INFO keyspace
CONFIG GET maxmemory
CONFIG GET maxmemory-policy
INFO memory
# The value that triggers eviction: used_memory - mem_not_counted_for_evict, compared with maxmemoryWhat it does
Shows evicted and expired key counts, the cache hit ratio, the share of keys with a TTL, and the memory value that triggers eviction relative to maxmemory.
When to use it
When the application gets 'OOM command not allowed when used memory > maxmemory', the cache hit ratio drops, or keys are reported to disappear unexpectedly.
Caution
With the noeviction policy, write commands get an OOM error once maxmemory is reached while reads keep working. With volatile-* policies keys without a TTL are never evicted; if there are no keys with a TTL it behaves like noeviction (check expires in INFO keyspace). Do not set maxmemory too close to physical RAM: leave room for replication buffers and copy-on-write during fork.