Find big keys (--bigkeys, --memkeys, MEMORY USAGE)
RedisMemoryCommand
# Largest keys per type by element count:
redis-cli -h redis1 -p 6379 --bigkeys -i 0.01
# By memory size:
redis-cli -h redis1 -p 6379 --memkeys -i 0.01
# Size and length together, top 20 keys (redis-cli 7.4+):
redis-cli -h redis1 -p 6379 --keystats --top 20 -i 0.01
# Memory usage (SAMPLES 0: all elements) and encoding of a single suspicious key:
redis-cli -h redis1 -p 6379 MEMORY USAGE kullanici:1001:sepet SAMPLES 0
redis-cli -h redis1 -p 6379 OBJECT ENCODING kullanici:1001:sepetWhat it does
Scans the keyspace with SCAN and reports the keys with the most elements and the most memory per type; shows the real memory consumption and encoding of a suspicious key.
When to use it
When memory grows unexpectedly, a single command (HGETALL, SMEMBERS, DEL) causes latency, or one node in a cluster uses more memory than the others.
Caution
The scan uses SCAN and does not block the server but walks the entire keyspace; -i 0.01 sleeps every 100 SCAN calls to reduce load. Deleting a big key with DEL blocks the main thread; use UNLINK. MEMORY USAGE with SAMPLES 0 is O(N) on large collections. Running it on a replica does not load the master.