forked from mirror/redis
Merge pull request #1220 from go-redis/fix/hmset-args
Fix HMSet args size
This commit is contained in:
commit
6c240ffc72
|
@ -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.
|
// Note that it uses HSET Redis command underneath because HMSET is deprecated.
|
||||||
func (c cmdable) HMSet(key string, values ...interface{}) *IntCmd {
|
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[0] = "hset"
|
||||||
args[1] = key
|
args[1] = key
|
||||||
args = appendArgs(args, values)
|
args = appendArgs(args, values)
|
||||||
|
|
|
@ -1367,9 +1367,7 @@ var _ = Describe("Commands", func() {
|
||||||
})
|
})
|
||||||
|
|
||||||
It("should HMGet", func() {
|
It("should HMGet", func() {
|
||||||
err := client.HSet("hash", "key1", "hello1").Err()
|
err := client.HMSet("hash", "key1", "hello1", "key2", "hello2").Err()
|
||||||
Expect(err).NotTo(HaveOccurred())
|
|
||||||
err = client.HSet("hash", "key2", "hello2").Err()
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
vals, err := client.HMGet("hash", "key1", "key2", "_").Result()
|
vals, err := client.HMGet("hash", "key1", "key2", "_").Result()
|
||||||
|
@ -1383,7 +1381,7 @@ var _ = Describe("Commands", func() {
|
||||||
"key2": "hello2",
|
"key2": "hello2",
|
||||||
}).Result()
|
}).Result()
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(ok).To(Equal(int64(3)))
|
Expect(ok).To(Equal(int64(2)))
|
||||||
|
|
||||||
v, err := client.HGet("hash", "key1").Result()
|
v, err := client.HGet("hash", "key1").Result()
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
@ -1392,6 +1390,10 @@ var _ = Describe("Commands", func() {
|
||||||
v, err = client.HGet("hash", "key2").Result()
|
v, err = client.HGet("hash", "key2").Result()
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(v).To(Equal("hello2"))
|
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() {
|
It("should HSet", func() {
|
||||||
|
|
Loading…
Reference in New Issue