Redis slowlog コマンド

Redis サーバー

Redis slowlog は、Redis がクエリ実行時間を記録するためのログシステムです。

クエリ実行時間とは、クライアント応答(talking)や応答送信などの IO 操作を含まず、単にクエリコマンドの実行にかかる時間を指します。

また、slow log はメモリ内に保存され、読み書き速度が非常に速いため、slow log を有効にすることで Redis の速度が損なわれる心配をせずに安心して使用できます。

構文

redis slowlog コマンドの基本的な構文は次のとおりです:

redis 127.0.0.1:6379> SLOWLOG subcommand [argument]

利用可能なバージョン

>= 2.2.12

戻り値

コマンドによって、異なる値を返します。

例

ログ情報を表示:

redis 127.0.0.1:6379> slowlog get 2
1) 1) (integer) 14
   2) (integer) 1309448221
   3) (integer) 15
   4) 1) "ping"
2) 1) (integer) 13
   2) (integer) 1309448128
   3) (integer) 30
   4) 1) "slowlog"
      2) "get"
      3) "100"

現在のログの数を表示:

redis 127.0.0.1:6379> SLOWLOG LEN
(integer) 14

コマンド SLOWLOG RESET を使用すると、slow log をクリアできます。

redis 127.0.0.1:6379> SLOWLOG LEN
(integer) 14

redis 127.0.0.1:6379> SLOWLOG RESET
OK

redis 127.0.0.1:6379> SLOWLOG LEN
(integer) 0

Redis サーバー

その他の拡張