redis関連コマンド

1693 ワード

bigkeysの検索
redis-cli--i 0.1--bigkeys//100 ms 1回実行
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)で