1
0
mirror of https://github.com/redis/go-redis.git synced 2025-07-28 06:42:00 +03:00

support for slowlog command

This commit is contained in:
wziww
2020-06-11 15:24:04 +08:00
committed by Vladimir Mihailenco
parent 4306c58d43
commit be9ae84c6f
4 changed files with 155 additions and 2 deletions

View File

@ -510,3 +510,21 @@ func ExampleNewUniversalClient_cluster() {
rdb.Ping(ctx)
}
func ExampleClient_SlowLog() {
var (
CONFIGSLOWKEY string = "slowlog-log-slower-than"
)
old := rdb.ConfigGet(ctx, CONFIGSLOWKEY).Val()
rdb.ConfigSet(ctx, CONFIGSLOWKEY, "0")
defer rdb.ConfigSet(ctx, CONFIGSLOWKEY, old[1].(string))
_, e := rdb.Eval(ctx, "redis.call('slowlog','reset')", []string{}).Result()
if e != nil && e != redis.Nil {
fmt.Println(e)
return
}
rdb.Set(ctx, "test", "true", 0)
result, err := rdb.SlowLog(ctx, -1).Result()
fmt.Println(len(result), err)
// Output: 3 <nil>
}