Skip to content

feat: Add support for new redis command CLIENT NO-TOUCH #2551

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 10 commits into from
14 changes: 14 additions & 0 deletions commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -3144,6 +3146,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 <option> [value] ... <option> [value]
Expand Down
10 changes: 10 additions & 0 deletions commands_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,16 @@ var _ = Describe("Commands", func() {
Expect(r.Val()).To(Equal(""))
})

It("should ClientNoTouch", func() {
r := client.ClientNoTouchOn(ctx)
Expect(r.Err()).NotTo(HaveOccurred())
Expect(r.Val()).To(Equal("OK"))

r = client.ClientNoTouchOff(ctx)
Expect(r.Err()).NotTo(HaveOccurred())
Expect(r.Val()).To(Equal("OK"))
})

It("should ClientKillByFilter", func() {
r := client.ClientKillByFilter(ctx, "TYPE", "test")
Expect(r.Err()).To(MatchError("ERR Unknown client type 'test'"))
Expand Down