Revert "Accept interface{} values in list and set commands."

This reverts commit 401979b597.
This commit is contained in:
Anatolii Mihailenco 2015-12-12 17:41:49 +02:00
parent 781f7f803d
commit 12edede26a
2 changed files with 26 additions and 47 deletions

View File

@ -767,17 +767,19 @@ func (c *commandable) LPop(key string) *StringCmd {
return cmd
}
func (c *commandable) LPush(key string, values ...interface{}) *IntCmd {
args := make([]interface{}, 2, 2+len(values))
func (c *commandable) LPush(key string, values ...string) *IntCmd {
args := make([]interface{}, 2+len(values))
args[0] = "LPUSH"
args[1] = key
args = append(args, values...)
for i, value := range values {
args[2+i] = value
}
cmd := NewIntCmd(args...)
c.Process(cmd)
return cmd
}
func (c *commandable) LPushX(key, value interface{}) *IntCmd {
func (c *commandable) LPushX(key, value string) *IntCmd {
cmd := NewIntCmd("LPUSHX", key, value)
c.Process(cmd)
return cmd
@ -794,13 +796,13 @@ func (c *commandable) LRange(key string, start, stop int64) *StringSliceCmd {
return cmd
}
func (c *commandable) LRem(key string, count int64, value interface{}) *IntCmd {
func (c *commandable) LRem(key string, count int64, value string) *IntCmd {
cmd := NewIntCmd("LREM", key, count, value)
c.Process(cmd)
return cmd
}
func (c *commandable) LSet(key string, index int64, value interface{}) *StatusCmd {
func (c *commandable) LSet(key string, index int64, value string) *StatusCmd {
cmd := NewStatusCmd("LSET", key, index, value)
c.Process(cmd)
return cmd
@ -829,17 +831,19 @@ func (c *commandable) RPopLPush(source, destination string) *StringCmd {
return cmd
}
func (c *commandable) RPush(key string, values ...interface{}) *IntCmd {
args := make([]interface{}, 2, 2+len(values))
func (c *commandable) RPush(key string, values ...string) *IntCmd {
args := make([]interface{}, 2+len(values))
args[0] = "RPUSH"
args[1] = key
args = append(args, values...)
for i, value := range values {
args[2+i] = value
}
cmd := NewIntCmd(args...)
c.Process(cmd)
return cmd
}
func (c *commandable) RPushX(key string, value interface{}) *IntCmd {
func (c *commandable) RPushX(key string, value string) *IntCmd {
cmd := NewIntCmd("RPUSHX", key, value)
c.Process(cmd)
return cmd
@ -847,11 +851,13 @@ func (c *commandable) RPushX(key string, value interface{}) *IntCmd {
//------------------------------------------------------------------------------
func (c *commandable) SAdd(key string, members ...interface{}) *IntCmd {
args := make([]interface{}, 2, 2+len(members))
func (c *commandable) SAdd(key string, members ...string) *IntCmd {
args := make([]interface{}, 2+len(members))
args[0] = "SADD"
args[1] = key
args = append(args, members...)
for i, member := range members {
args[2+i] = member
}
cmd := NewIntCmd(args...)
c.Process(cmd)
return cmd
@ -909,7 +915,7 @@ func (c *commandable) SInterStore(destination string, keys ...string) *IntCmd {
return cmd
}
func (c *commandable) SIsMember(key string, member interface{}) *BoolCmd {
func (c *commandable) SIsMember(key, member string) *BoolCmd {
cmd := NewBoolCmd("SISMEMBER", key, member)
c.Process(cmd)
return cmd
@ -921,7 +927,7 @@ func (c *commandable) SMembers(key string) *StringSliceCmd {
return cmd
}
func (c *commandable) SMove(source, destination string, member interface{}) *BoolCmd {
func (c *commandable) SMove(source, destination, member string) *BoolCmd {
cmd := NewBoolCmd("SMOVE", source, destination, member)
c.Process(cmd)
return cmd
@ -947,11 +953,13 @@ func (c *commandable) SRandMemberN(key string, count int64) *StringSliceCmd {
return cmd
}
func (c *commandable) SRem(key string, members ...interface{}) *IntCmd {
args := make([]interface{}, 2, 2+len(members))
func (c *commandable) SRem(key string, members ...string) *IntCmd {
args := make([]interface{}, 2+len(members))
args[0] = "SREM"
args[1] = key
args = append(args, members...)
for i, member := range members {
args[2+i] = member
}
cmd := NewIntCmd(args...)
c.Process(cmd)
return cmd

View File

@ -1379,17 +1379,6 @@ var _ = Describe("Commands", func() {
Expect(lRange.Val()).To(Equal([]string{"Hello", "World"}))
})
It("should LPush bytes", func() {
lPush := client.LPush("list", []byte("World"))
Expect(lPush.Err()).NotTo(HaveOccurred())
lPush = client.LPush("list", []byte("Hello"))
Expect(lPush.Err()).NotTo(HaveOccurred())
lRange := client.LRange("list", 0, -1)
Expect(lRange.Err()).NotTo(HaveOccurred())
Expect(lRange.Val()).To(Equal([]string{"Hello", "World"}))
})
It("should LPushX", func() {
lPush := client.LPush("list", "World")
Expect(lPush.Err()).NotTo(HaveOccurred())
@ -1589,24 +1578,6 @@ var _ = Describe("Commands", func() {
Expect(sMembers.Val()).To(ConsistOf([]string{"Hello", "World"}))
})
It("should SAdd bytes", func() {
sAdd := client.SAdd("set", []byte("Hello"))
Expect(sAdd.Err()).NotTo(HaveOccurred())
Expect(sAdd.Val()).To(Equal(int64(1)))
sAdd = client.SAdd("set", []byte("World"))
Expect(sAdd.Err()).NotTo(HaveOccurred())
Expect(sAdd.Val()).To(Equal(int64(1)))
sAdd = client.SAdd("set", []byte("World"))
Expect(sAdd.Err()).NotTo(HaveOccurred())
Expect(sAdd.Val()).To(Equal(int64(0)))
sMembers := client.SMembers("set")
Expect(sMembers.Err()).NotTo(HaveOccurred())
Expect(sMembers.Val()).To(ConsistOf([]string{"Hello", "World"}))
})
It("should SCard", func() {
sAdd := client.SAdd("set", "Hello")
Expect(sAdd.Err()).NotTo(HaveOccurred())