OOM command not allowed when used memory > 'maxmemory'
MISCONF Redis is configured to save RDB snapshots, but it's currently unable to persist to disk.
Redis ran out of its allocated memory and is rejecting write commands.
Fix 1: Increase maxmemory
# Check current setting
redis-cli CONFIG GET maxmemory
# Increase it
redis-cli CONFIG SET maxmemory 512mb
# Permanent: add to redis.conf
maxmemory 512mb
Fix 2: Set an Eviction Policy
# β Default: noeviction β rejects writes when full
# β
Set a policy to automatically remove old keys
redis-cli CONFIG SET maxmemory-policy allkeys-lru
# Options:
# allkeys-lru β evict least recently used keys (most common)
# volatile-lru β evict LRU keys with TTL set
# allkeys-random β evict random keys
# volatile-ttl β evict keys closest to expiration
Fix 3: Add TTL to Keys
# β Keys without TTL stay forever
SET mykey "value"
# β
Always set expiration
SET mykey "value" EX 3600 # Expires in 1 hour
SETEX mykey 3600 "value" # Same thing
Fix 4: Find Large Keys
# Find the biggest keys
redis-cli --bigkeys
# Check memory usage of a specific key
redis-cli MEMORY USAGE mykey
Fix 5: Check Whatβs Using Memory
# Memory breakdown
redis-cli INFO memory
# Key count by pattern
redis-cli --scan --pattern "session:*" | wc -l
redis-cli --scan --pattern "cache:*" | wc -l
Fix 6: Flush Stale Data
# Delete all keys matching a pattern
redis-cli --scan --pattern "old:*" | xargs redis-cli DEL
# β οΈ Nuclear option: flush everything
redis-cli FLUSHALL
Related resources
Related: PostgreSQL Cheat Sheet