forked from mirror/redis
Add unlink command.
This commit is contained in:
parent
754e4ed906
commit
0f05d8df9d
12
commands.go
12
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)
|
||||
|
|
|
@ -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() {
|
||||
|
|
Loading…
Reference in New Issue