场景
随着时间流逝,redis内存逐步增大,需要对redis内存进行清理,发现问题,解决问题。
方案
bigkeys
命令用于识别在 Redis 数据库中占用最多内存的键。
对服务有一定开销,在使用系统低峰期操作。
redis-cli -c -h 127.0.0.1 -p 7021 --bigkeys
输出结果
# Scanning the entire keyspace to find biggest keys as well as
# average sizes per key type. You can use -i 0.1 to sleep 0.1 sec
# per 100 SCAN commands (not usually needed).
[00.00%] Biggest string found so far '"xxx22"' with 172 bytes
[00.45%] Biggest hash found so far '"xx111"' with 1 fields
....
[06.72%] Biggest list found so far '"lizzList"' with 1 items
...
[39.70%] Biggest set found so far '"setlizz:20"' with 8 members
[50.22%] Biggest hash found so far '"hashlizz:123123"' with 2480 fields
[85.93%] Biggest string