Merge pull request #2237 from injeniero/fix-info-section-vargs

fix: use all provided sections
This commit is contained in:
Vladimir Mihailenco 2022-10-08 08:53:31 +03:00 committed by GitHub
commit d7dd9a732d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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())