1
0
mirror of https://github.com/redis/go-redis.git synced 2025-07-29 17:41:15 +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

@ -4013,6 +4013,24 @@ var _ = Describe("Commands", func() {
Expect(vals).To(Equal([]interface{}{int64(12), proto.RedisError("error"), "abc"}))
})
})
Describe("SlowLog", func() {
It("returns slow query result", func() {
var CONFIGSLOWKEY string = "slowlog-log-slower-than"
old := client.ConfigGet(ctx, CONFIGSLOWKEY).Val()
client.ConfigSet(ctx, CONFIGSLOWKEY, "0")
defer client.ConfigSet(ctx, CONFIGSLOWKEY, old[1].(string))
_, e := client.Eval(ctx, "redis.call('slowlog','reset')", []string{}).Result()
if e != nil && e != redis.Nil {
fmt.Println(e)
return
}
client.Set(ctx, "test", "true", 0)
result, err := client.SlowLog(ctx, -1).Result()
Expect(err).NotTo(HaveOccurred())
Expect(len(result)).To(Equal(3))
})
})
})
type numberStruct struct {