From 5887cbb23243325f1f0ea595e778d5a5e82d5108 Mon Sep 17 00:00:00 2001 From: ktsivkov Date: Tue, 18 Apr 2023 16:11:31 +0200 Subject: [PATCH 1/5] Implemented feature for `CLIENT NO-TOUCH ` --- commands.go | 12 ++++++++++++ commands_test.go | 10 ++++++++++ 2 files changed, 22 insertions(+) diff --git a/commands.go b/commands.go index 3721df4e1..548f76e8f 100644 --- a/commands.go +++ b/commands.go @@ -407,6 +407,7 @@ type Cmdable interface { ClientID(ctx context.Context) *IntCmd ClientUnblock(ctx context.Context, id int64) *IntCmd ClientUnblockWithError(ctx context.Context, id int64) *IntCmd + ClientNoTouch(ctx context.Context, value bool) *BoolCmd ConfigGet(ctx context.Context, parameter string) *MapStringStringCmd ConfigResetStat(ctx context.Context) *StatusCmd ConfigSet(ctx context.Context, parameter, value string) *StatusCmd @@ -3174,6 +3175,17 @@ func (c cmdable) ClientUnblockWithError(ctx context.Context, id int64) *IntCmd { return cmd } +func (c cmdable) ClientNoTouch(ctx context.Context, value bool) *BoolCmd { + val := "OFF" + if value { + val = "ON" + } + + cmd := NewBoolCmd(ctx, "client", "no-touch", val) + _ = c(ctx, cmd) + return cmd +} + func (c cmdable) ConfigGet(ctx context.Context, parameter string) *MapStringStringCmd { cmd := NewMapStringStringCmd(ctx, "config", "get", parameter) _ = c(ctx, cmd) diff --git a/commands_test.go b/commands_test.go index e20470f2d..026da8031 100644 --- a/commands_test.go +++ b/commands_test.go @@ -225,6 +225,16 @@ var _ = Describe("Commands", func() { Expect(get.Val()).To(Equal("theclientname")) }) + It("should ClientNoTouch", func() { + noTouchOn := client.ClientNoTouch(ctx, true) + Expect(noTouchOn.Err()).NotTo(HaveOccurred()) + Expect(noTouchOn.Val()).To(BeTrue()) + + noTouchOff := client.ClientNoTouch(ctx, true) + Expect(noTouchOff.Err()).NotTo(HaveOccurred()) + Expect(noTouchOff.Val()).To(BeTrue()) + }) + It("should ConfigGet", func() { val, err := client.ConfigGet(ctx, "*").Result() Expect(err).NotTo(HaveOccurred()) From 2c04529091b02bb52570aa58cdee8078c801a077 Mon Sep 17 00:00:00 2001 From: Anuragkillswitch <70265851+Anuragkillswitch@users.noreply.github.com> Date: Fri, 21 Apr 2023 19:36:04 +0530 Subject: [PATCH 2/5] move: commands to StatusCmd --- commands.go | 14 ++++++++++++++ commands_test.go | 10 ++++++++++ 2 files changed, 24 insertions(+) diff --git a/commands.go b/commands.go index 03055c904..0b5b5d632 100644 --- a/commands.go +++ b/commands.go @@ -167,6 +167,8 @@ type Cmdable interface { CommandGetKeys(ctx context.Context, commands ...interface{}) *StringSliceCmd CommandGetKeysAndFlags(ctx context.Context, commands ...interface{}) *KeyFlagsCmd ClientGetName(ctx context.Context) *StringCmd + ClientNoTouchON(ctx context.Context) *StatusCmd + ClientNoTouchOFF(ctx context.Context) *StatusCmd Echo(ctx context.Context, message interface{}) *StringCmd Ping(ctx context.Context) *StatusCmd Quit(ctx context.Context) *StatusCmd @@ -3141,6 +3143,18 @@ func (c cmdable) ClientKill(ctx context.Context, ipPort string) *StatusCmd { return cmd } +func (c cmdable) ClientNoTouchON(ctx context.Context) *StatusCmd { + cmd := NewStatusCmd(ctx, "client", "no-touch", "on") + _ = c(ctx, cmd) + return cmd +} + +func (c cmdable) ClientNoTouchOFF(ctx context.Context) *StatusCmd { + cmd := NewStatusCmd(ctx, "client", "no-touch", "off") + _ = c(ctx, cmd) + return cmd +} + // ClientKillByFilter is new style syntax, while the ClientKill is old // // CLIENT KILL