Merge pull request #821 from git-hulk/feature/supports-new-style-syntax-client-kill

Supports new style syntax of client kill command
This commit is contained in:
Vladimir Mihailenco 2018-07-24 09:07:52 +03:00 committed by GitHub
commit c696191b80
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 0 deletions

View File

@ -220,6 +220,7 @@ type Cmdable interface {
BgRewriteAOF() *StatusCmd
BgSave() *StatusCmd
ClientKill(ipPort string) *StatusCmd
ClientKillByFilter(keys ...string) *IntCmd
ClientList() *StringCmd
ClientPause(dur time.Duration) *BoolCmd
ConfigGet(parameter string) *SliceCmd
@ -1822,6 +1823,20 @@ func (c *cmdable) ClientKill(ipPort string) *StatusCmd {
return cmd
}
// ClientKillByFilter is new style synx, while the ClientKill is old
// CLIENT KILL <option> [value] ... <option> [value]
func (c *cmdable) ClientKillByFilter(keys ...string) *IntCmd {
args := make([]interface{}, 2+len(keys))
args[0] = "client"
args[1] = "kill"
for i, key := range keys {
args[2+i] = key
}
cmd := NewIntCmd(args...)
c.process(cmd)
return cmd
}
func (c *cmdable) ClientList() *StringCmd {
cmd := NewStringCmd("client", "list")
c.process(cmd)

View File

@ -115,6 +115,12 @@ var _ = Describe("Commands", func() {
Expect(r.Val()).To(Equal(""))
})
It("should ClientKillByFilter", func() {
r := client.ClientKillByFilter("TYPE", "test")
Expect(r.Err()).To(MatchError("ERR Unknown client type 'test'"))
Expect(r.Val()).To(Equal(int64(0)))
})
It("should ClientPause", func() {
err := client.ClientPause(time.Second).Err()
Expect(err).NotTo(HaveOccurred())