fix: use all provided sections

This commit is contained in:
Simon Paredes 2022-10-07 16:40:51 -03:00 committed by Simon Paredes
parent dd9a200427
commit 28028b330f
2 changed files with 26 additions and 13 deletions

View File

@ -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, // ZREVRANGE,
// ZRANGEBYSCORE, // ZRANGEBYSCORE,
// ZREVRANGEBYSCORE, // ZREVRANGEBYSCORE,
// ZRANGEBYLEX, // ZRANGEBYLEX,
// ZREVRANGEBYLEX. // 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.
@ -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)

View File

@ -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())