当redis被用作缓存时,有时我们希望了解key的大小分布,或者想知道哪些key占的空间比较大。本文提供了几种方法。 一. bigKeys 这是redis-cli自带的一个命令。对整个redis进行扫描,寻找较大的key。例: redis-cli -h b.redis -p 1959 --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 hash found so far 's_9329222' with 3 fields [00.00%] Biggest string found so far 'url_http://mini.eastday.com/mobile/170722090206890.html?qid=sgllq&ch=east_sogou_push&pushid=13' with 8 bytes [00.00%] Biggest string found so far 'foo' with 40 bytes [00.00%] Biggest hash found so far 's_9329084' with 4 fields [00.23%] Biggest zset found so far 'region_hot_菏泽地' with 625 members [00.23%] Biggest zset found so far 'region_hot_葫芦岛' with 914 members [00.47%] Biggest string found so far 'top_notice_list' with 135193 bytes [00.73%] ...
评论