forked from mirror/redis
Supports new style syntax of client kill command
This commit is contained in:
parent
3143c672b6
commit
bbcb2b7988
15
commands.go
15
commands.go
|
@ -220,6 +220,7 @@ type Cmdable interface {
|
||||||
BgRewriteAOF() *StatusCmd
|
BgRewriteAOF() *StatusCmd
|
||||||
BgSave() *StatusCmd
|
BgSave() *StatusCmd
|
||||||
ClientKill(ipPort string) *StatusCmd
|
ClientKill(ipPort string) *StatusCmd
|
||||||
|
ClientKillByFilter(keys ...string) *IntCmd
|
||||||
ClientList() *StringCmd
|
ClientList() *StringCmd
|
||||||
ClientPause(dur time.Duration) *BoolCmd
|
ClientPause(dur time.Duration) *BoolCmd
|
||||||
ConfigGet(parameter string) *SliceCmd
|
ConfigGet(parameter string) *SliceCmd
|
||||||
|
@ -1822,6 +1823,20 @@ func (c *cmdable) ClientKill(ipPort string) *StatusCmd {
|
||||||
return cmd
|
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 {
|
func (c *cmdable) ClientList() *StringCmd {
|
||||||
cmd := NewStringCmd("client", "list")
|
cmd := NewStringCmd("client", "list")
|
||||||
c.process(cmd)
|
c.process(cmd)
|
||||||
|
|
|
@ -115,6 +115,12 @@ var _ = Describe("Commands", func() {
|
||||||
Expect(r.Val()).To(Equal(""))
|
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() {
|
It("should ClientPause", func() {
|
||||||
err := client.ClientPause(time.Second).Err()
|
err := client.ClientPause(time.Second).Err()
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
|
Loading…
Reference in New Issue