diff --git a/commands.go b/commands.go index 89a70b60..5bbcc104 100644 --- a/commands.go +++ b/commands.go @@ -47,6 +47,7 @@ type Cmdable interface { Ping() *StatusCmd Quit() *StatusCmd Del(keys ...string) *IntCmd + Unlink(keys ...string) *IntCmd Dump(key string) *StringCmd Exists(key string) *BoolCmd Expire(key string, expiration time.Duration) *BoolCmd @@ -292,6 +293,17 @@ func (c *cmdable) Del(keys ...string) *IntCmd { return cmd } +func (c *cmdable) Unlink(keys ...string) *IntCmd { + args := make([]interface{}, 1+len(keys)) + args[0] = "unlink" + for i, key := range keys { + args[1+i] = key + } + cmd := NewIntCmd(args...) + c.process(cmd) + return cmd +} + func (c *cmdable) Dump(key string) *StringCmd { cmd := NewStringCmd("dump", key) c.process(cmd) diff --git a/commands_test.go b/commands_test.go index dba37aac..226300e8 100644 --- a/commands_test.go +++ b/commands_test.go @@ -199,16 +199,25 @@ var _ = Describe("Commands", func() { Describe("keys", func() { It("should Del", func() { - set := client.Set("key1", "Hello", 0) - Expect(set.Err()).NotTo(HaveOccurred()) - Expect(set.Val()).To(Equal("OK")) - set = client.Set("key2", "World", 0) - Expect(set.Err()).NotTo(HaveOccurred()) - Expect(set.Val()).To(Equal("OK")) + err := client.Set("key1", "Hello", 0).Err() + Expect(err).NotTo(HaveOccurred()) + err = client.Set("key2", "World", 0).Err() + Expect(err).NotTo(HaveOccurred()) - del := client.Del("key1", "key2", "key3") - Expect(del.Err()).NotTo(HaveOccurred()) - Expect(del.Val()).To(Equal(int64(2))) + n, err := client.Del("key1", "key2", "key3").Result() + Expect(err).NotTo(HaveOccurred()) + Expect(n).To(Equal(int64(2))) + }) + + It("should Unlink", func() { + err := client.Set("key1", "Hello", 0).Err() + Expect(err).NotTo(HaveOccurred()) + err = client.Set("key2", "World", 0).Err() + Expect(err).NotTo(HaveOccurred()) + + n, err := client.Unlink("key1", "key2", "key3").Result() + Expect(err).NotTo(HaveOccurred()) + Expect(n).To(Equal(int64(2))) }) It("should Dump", func() {