Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Redis Slowlog Command

Redis slowlog command

Redis Server

Redis slowlog is the logging system Redis uses to record query execution times.

Query execution time refers to the time spent executing a query command only, excluding IO operations such as client response (talking) and sending replies.

In addition, the slow log is kept in memory and is very fast to read and write, so you can use it with confidence without worrying that enabling the slow log will harm Redis's speed.

Syntax

The basic syntax of the redis slowlog command is as follows:



redis 127.0.0.1:6379> SLOWLOG subcommand [argument]

Available Version

= 2.2.12

Return Value

Returns different values depending on the command.

Example

View log information:



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"

View the current number of logs:



redis 127.0.0.1:6379> SLOWLOG LEN

(integer) 14

Use the command SLOWLOG RESET to clear the 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 Server