mirror of https://github.com/go-redis/redis.git
fix: use all provided sections
This commit is contained in:
parent
dd9a200427
commit
28028b330f
31
commands.go
31
commands.go
|
@ -13,7 +13,7 @@ import (
|
||||||
// otherwise you will receive an error: (error) ERR syntax error.
|
// otherwise you will receive an error: (error) ERR syntax error.
|
||||||
// For example:
|
// For example:
|
||||||
//
|
//
|
||||||
// rdb.Set(ctx, key, value, redis.KeepTTL)
|
// rdb.Set(ctx, key, value, redis.KeepTTL)
|
||||||
const KeepTTL = -1
|
const KeepTTL = -1
|
||||||
|
|
||||||
func usePrecise(dur time.Duration) bool {
|
func usePrecise(dur time.Duration) bool {
|
||||||
|
@ -2052,8 +2052,10 @@ func xClaimArgs(a *XClaimArgs) []interface{} {
|
||||||
|
|
||||||
// xTrim If approx is true, add the "~" parameter, otherwise it is the default "=" (redis default).
|
// xTrim If approx is true, add the "~" parameter, otherwise it is the default "=" (redis default).
|
||||||
// example:
|
// example:
|
||||||
// XTRIM key MAXLEN/MINID threshold LIMIT limit.
|
//
|
||||||
// XTRIM key MAXLEN/MINID ~ threshold LIMIT limit.
|
// XTRIM key MAXLEN/MINID threshold LIMIT limit.
|
||||||
|
// XTRIM key MAXLEN/MINID ~ threshold LIMIT limit.
|
||||||
|
//
|
||||||
// The redis-server version is lower than 6.2, please set limit to 0.
|
// The redis-server version is lower than 6.2, please set limit to 0.
|
||||||
func (c cmdable) xTrim(
|
func (c cmdable) xTrim(
|
||||||
ctx context.Context, key, strategy string,
|
ctx context.Context, key, strategy string,
|
||||||
|
@ -2391,11 +2393,13 @@ func (c cmdable) ZPopMin(ctx context.Context, key string, count ...int64) *ZSlic
|
||||||
|
|
||||||
// ZRangeArgs is all the options of the ZRange command.
|
// ZRangeArgs is all the options of the ZRange command.
|
||||||
// In version> 6.2.0, you can replace the(cmd):
|
// In version> 6.2.0, you can replace the(cmd):
|
||||||
// ZREVRANGE,
|
//
|
||||||
// ZRANGEBYSCORE,
|
// ZREVRANGE,
|
||||||
// ZREVRANGEBYSCORE,
|
// ZRANGEBYSCORE,
|
||||||
// ZRANGEBYLEX,
|
// ZREVRANGEBYSCORE,
|
||||||
// ZREVRANGEBYLEX.
|
// ZRANGEBYLEX,
|
||||||
|
// ZREVRANGEBYLEX.
|
||||||
|
//
|
||||||
// Please pay attention to your redis-server version.
|
// Please pay attention to your redis-server version.
|
||||||
//
|
//
|
||||||
// Rev, ByScore, ByLex and Offset+Count options require redis-server 6.2.0 and higher.
|
// Rev, ByScore, ByLex and Offset+Count options require redis-server 6.2.0 and higher.
|
||||||
|
@ -2799,7 +2803,7 @@ func (c cmdable) ClientKill(ctx context.Context, ipPort string) *StatusCmd {
|
||||||
|
|
||||||
// ClientKillByFilter is new style syntax, while the ClientKill is old
|
// ClientKillByFilter is new style syntax, while the ClientKill is old
|
||||||
//
|
//
|
||||||
// CLIENT KILL <option> [value] ... <option> [value]
|
// CLIENT KILL <option> [value] ... <option> [value]
|
||||||
func (c cmdable) ClientKillByFilter(ctx context.Context, keys ...string) *IntCmd {
|
func (c cmdable) ClientKillByFilter(ctx context.Context, keys ...string) *IntCmd {
|
||||||
args := make([]interface{}, 2+len(keys))
|
args := make([]interface{}, 2+len(keys))
|
||||||
args[0] = "client"
|
args[0] = "client"
|
||||||
|
@ -2902,10 +2906,11 @@ func (c cmdable) FlushDBAsync(ctx context.Context) *StatusCmd {
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c cmdable) Info(ctx context.Context, section ...string) *StringCmd {
|
func (c cmdable) Info(ctx context.Context, sections ...string) *StringCmd {
|
||||||
args := []interface{}{"info"}
|
args := make([]interface{}, 1+len(sections))
|
||||||
if len(section) > 0 {
|
args[0] = "info"
|
||||||
args = append(args, section[0])
|
for i, section := range sections {
|
||||||
|
args[i+1] = section
|
||||||
}
|
}
|
||||||
cmd := NewStringCmd(ctx, args...)
|
cmd := NewStringCmd(ctx, args...)
|
||||||
_ = c(ctx, cmd)
|
_ = c(ctx, cmd)
|
||||||
|
|
|
@ -227,6 +227,14 @@ var _ = Describe("Commands", func() {
|
||||||
Expect(info.Val()).To(ContainSubstring(`used_cpu_sys`))
|
Expect(info.Val()).To(ContainSubstring(`used_cpu_sys`))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
It("should Info cpu and memory", func() {
|
||||||
|
info := client.Info(ctx, "cpu", "memory")
|
||||||
|
Expect(info.Err()).NotTo(HaveOccurred())
|
||||||
|
Expect(info.Val()).NotTo(Equal(""))
|
||||||
|
Expect(info.Val()).To(ContainSubstring(`used_cpu_sys`))
|
||||||
|
Expect(info.Val()).To(ContainSubstring(`memory`))
|
||||||
|
})
|
||||||
|
|
||||||
It("should LastSave", func() {
|
It("should LastSave", func() {
|
||||||
lastSave := client.LastSave(ctx)
|
lastSave := client.LastSave(ctx)
|
||||||
Expect(lastSave.Err()).NotTo(HaveOccurred())
|
Expect(lastSave.Err()).NotTo(HaveOccurred())
|
||||||
|
|
Loading…
Reference in New Issue