Fix HMSet args size

This commit is contained in:
Vladimir Mihailenco 2019-12-24 12:23:32 +02:00
parent 0658532833
commit 071b053edd
2 changed files with 7 additions and 5 deletions

View File

@ -988,7 +988,7 @@ func (c cmdable) HMGet(key string, fields ...string) *SliceCmd {
//
// Note that it uses HSET Redis command underneath because HMSET is deprecated.
func (c cmdable) HMSet(key string, values ...interface{}) *IntCmd {
args := make([]interface{}, 2+2*len(values))
args := make([]interface{}, 2, 2+len(values))
args[0] = "hset"
args[1] = key
args = appendArgs(args, values)

View File

@ -1367,9 +1367,7 @@ var _ = Describe("Commands", func() {
})
It("should HMGet", func() {
err := client.HSet("hash", "key1", "hello1").Err()
Expect(err).NotTo(HaveOccurred())
err = client.HSet("hash", "key2", "hello2").Err()
err := client.HMSet("hash", "key1", "hello1", "key2", "hello2").Err()
Expect(err).NotTo(HaveOccurred())
vals, err := client.HMGet("hash", "key1", "key2", "_").Result()
@ -1383,7 +1381,7 @@ var _ = Describe("Commands", func() {
"key2": "hello2",
}).Result()
Expect(err).NotTo(HaveOccurred())
Expect(ok).To(Equal(int64(3)))
Expect(ok).To(Equal(int64(2)))
v, err := client.HGet("hash", "key1").Result()
Expect(err).NotTo(HaveOccurred())
@ -1392,6 +1390,10 @@ var _ = Describe("Commands", func() {
v, err = client.HGet("hash", "key2").Result()
Expect(err).NotTo(HaveOccurred())
Expect(v).To(Equal("hello2"))
keys, err := client.HKeys("hash").Result()
Expect(err).NotTo(HaveOccurred())
Expect(keys).To(ConsistOf([]string{"key1", "key2"}))
})
It("should HSet", func() {