From 2672a0fbf276b60816a2ae37584a63571630dd84 Mon Sep 17 00:00:00 2001 From: Theo Date: Tue, 11 Dec 2018 10:43:54 +0000 Subject: [PATCH] Add Client Id --- commands.go | 7 +++++++ commands_test.go | 8 +++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/commands.go b/commands.go index 85262cca..6e873f22 100644 --- a/commands.go +++ b/commands.go @@ -231,6 +231,7 @@ type Cmdable interface { ClientKillByFilter(keys ...string) *IntCmd ClientList() *StringCmd ClientPause(dur time.Duration) *BoolCmd + ClientId() *IntCmd ConfigGet(parameter string) *SliceCmd ConfigResetStat() *StatusCmd ConfigSet(parameter, value string) *StatusCmd @@ -2061,6 +2062,12 @@ func (c *cmdable) ClientPause(dur time.Duration) *BoolCmd { return cmd } +func (c *cmdable) ClientId() *IntCmd { + cmd := NewIntCmd("client", "id") + c.process(cmd) + return cmd +} + // ClientSetName assigns a name to the connection. func (c *statefulCmdable) ClientSetName(name string) *BoolCmd { cmd := NewBoolCmd("client", "setname", name) diff --git a/commands_test.go b/commands_test.go index 2dba77c9..ecca35c4 100644 --- a/commands_test.go +++ b/commands_test.go @@ -121,6 +121,12 @@ var _ = Describe("Commands", func() { Expect(r.Val()).To(Equal(int64(0))) }) + It("should ClientId", func() { + err := client.ClientId().Err() + Expect(err).NotTo(HaveOccurred()) + Expect(client.ClientId().Val()).To(BeNumerically(">=", 0)) + }) + It("should ClientPause", func() { err := client.ClientPause(time.Second).Err() Expect(err).NotTo(HaveOccurred()) @@ -222,7 +228,7 @@ var _ = Describe("Commands", func() { Expect(tm).To(BeTemporally("~", time.Now(), 3*time.Second)) }) - It("Should Command", func() { + It("should Command", func() { cmds, err := client.Command().Result() Expect(err).NotTo(HaveOccurred()) Expect(len(cmds)).To(BeNumerically("~", 200, 20))