Redis slowlog 命令
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

