Skip to content

Commit d7dd9a7

Browse files
authored
Merge pull request #2237 from injeniero/fix-info-section-vargs
fix: use all provided sections
2 parents dd9a200 + 28028b3 commit d7dd9a7

File tree

2 files changed

+26
-13
lines changed

2 files changed

+26
-13
lines changed

commands.go

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
// otherwise you will receive an error: (error) ERR syntax error.
1414
// For example:
1515
//
16-
// rdb.Set(ctx, key, value, redis.KeepTTL)
16+
// rdb.Set(ctx, key, value, redis.KeepTTL)
1717
const KeepTTL = -1
1818

1919
func usePrecise(dur time.Duration) bool {
@@ -2052,8 +2052,10 @@ func xClaimArgs(a *XClaimArgs) []interface{} {
20522052

20532053
// xTrim If approx is true, add the "~" parameter, otherwise it is the default "=" (redis default).
20542054
// example:
2055-
// XTRIM key MAXLEN/MINID threshold LIMIT limit.
2056-
// XTRIM key MAXLEN/MINID ~ threshold LIMIT limit.
2055+
//
2056+
// XTRIM key MAXLEN/MINID threshold LIMIT limit.
2057+
// XTRIM key MAXLEN/MINID ~ threshold LIMIT limit.
2058+
//
20572059
// The redis-server version is lower than 6.2, please set limit to 0.
20582060
func (c cmdable) xTrim(
20592061
ctx context.Context, key, strategy string,
@@ -2391,11 +2393,13 @@ func (c cmdable) ZPopMin(ctx context.Context, key string, count ...int64) *ZSlic
23912393

23922394
// ZRangeArgs is all the options of the ZRange command.
23932395
// In version> 6.2.0, you can replace the(cmd):
2394-
// ZREVRANGE,
2395-
// ZRANGEBYSCORE,
2396-
// ZREVRANGEBYSCORE,
2397-
// ZRANGEBYLEX,
2398-
// ZREVRANGEBYLEX.
2396+
//
2397+
// ZREVRANGE,
2398+
// ZRANGEBYSCORE,
2399+
// ZREVRANGEBYSCORE,
2400+
// ZRANGEBYLEX,
2401+
// ZREVRANGEBYLEX.
2402+
//
23992403
// Please pay attention to your redis-server version.
24002404
//
24012405
// 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 {
27992803

28002804
// ClientKillByFilter is new style syntax, while the ClientKill is old
28012805
//
2802-
// CLIENT KILL <option> [value] ... <option> [value]
2806+
// CLIENT KILL <option> [value] ... <option> [value]
28032807
func (c cmdable) ClientKillByFilter(ctx context.Context, keys ...string) *IntCmd {
28042808
args := make([]interface{}, 2+len(keys))
28052809
args[0] = "client"
@@ -2902,10 +2906,11 @@ func (c cmdable) FlushDBAsync(ctx context.Context) *StatusCmd {
29022906
return cmd
29032907
}
29042908

2905-
func (c cmdable) Info(ctx context.Context, section ...string) *StringCmd {
2906-
args := []interface{}{"info"}
2907-
if len(section) > 0 {
2908-
args = append(args, section[0])
2909+
func (c cmdable) Info(ctx context.Context, sections ...string) *StringCmd {
2910+
args := make([]interface{}, 1+len(sections))
2911+
args[0] = "info"
2912+
for i, section := range sections {
2913+
args[i+1] = section
29092914
}
29102915
cmd := NewStringCmd(ctx, args...)
29112916
_ = c(ctx, cmd)

commands_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,14 @@ var _ = Describe("Commands", func() {
227227
Expect(info.Val()).To(ContainSubstring(`used_cpu_sys`))
228228
})
229229

230+
It("should Info cpu and memory", func() {
231+
info := client.Info(ctx, "cpu", "memory")
232+
Expect(info.Err()).NotTo(HaveOccurred())
233+
Expect(info.Val()).NotTo(Equal(""))
234+
Expect(info.Val()).To(ContainSubstring(`used_cpu_sys`))
235+
Expect(info.Val()).To(ContainSubstring(`memory`))
236+
})
237+
230238
It("should LastSave", func() {
231239
lastSave := client.LastSave(ctx)
232240
Expect(lastSave.Err()).NotTo(HaveOccurred())

0 commit comments

Comments
 (0)