redis 相关命令

36次阅读

共计 1277 个字符,预计需要花费 4 分钟才能阅读完成。

查找 bigkeys
redis-cli –i 0.1 –bigkeys //100ms 执行一次
redis-cli -a yaoran -r 3 -i 0.01 –bigkeys
Warning: Using a password with ‘-a’ or ‘-u’ option on the command line interface may not be safe.

# 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 ‘aaaa’ with 3 bytes
[00.00%] Biggest string found so far ‘ab:cdd:dfew:dfew:dfwefe:ewfew:ewww:ewfew:ewfew:ewfwef:efwfew:fewfe:fewfe:ss’ with 31 bytes

——– summary ——-

Sampled 5 keys in the keyspace!
Total key length in bytes is 89 (avg len 17.80)

Biggest string found ‘ab:cdd:dfew:dfew:dfwefe:ewfew:ewww:ewfew:ewfew:ewfwef:efwfew:fewfe:fewfe:ss’ has 31 bytes

5 strings with 42 bytes (100.00% of keys, avg size 8.40)
0 lists with 0 items (00.00% of keys, avg size 0.00)
0 sets with 0 members (00.00% of keys, avg size 0.00)
0 hashs with 0 fields (00.00% of keys, avg size 0.00)
0 zsets with 0 members (00.00% of keys, avg size 0.00)
0 streams with 0 entries (00.00% of keys, avg size 0.00)
查看 value 的具体信息
127.0.0.1:6379> debug object jsonbig
Value at:0x7fe2d4d087c0 refcount:1 encoding:raw serializedlength:151 lru:9712799 lru_seconds_idle:10
serializedlength 代表 key 对应的 value 序列化的字节数,如果是字符串,也可以用 strlen 来查看
127.0.0.1:6379> strlen jsonbig
(integer) 1664
查看占用内存
redis4.0 之后可以用 memory usage 查看 key 的占用内存
127.0.0.1:6379> memory usage jsonbig
(integer) 1719
数据量大的话可以用 scan + memory usage(pipline)

正文完
 0