1
0
mirror of https://github.com/redis/go-redis.git synced 2025-08-06 01:35:48 +03:00

Add support for resp3 protocol (#1739)

* support resp3 protocol

Signed-off-by: monkey <golang@88.com>

* Upgrade mod version limit go1.14

https://github.com/go-redis/redis/issues/1715#issuecomment-820685614

Signed-off-by: monkey <golang@88.com>

* Remove the redundant check of ReadReply

Signed-off-by: monkey <golang@88.com>

* fix the problem

Signed-off-by: monkey <golang@88.com>

* workflows add v9

Signed-off-by: monkey <golang@88.com>

* update StringStringMapCmd to MapStringStringCmd

Signed-off-by: monkey <golang@88.com>
This commit is contained in:
monkey92t
2021-04-27 15:04:46 +08:00
committed by GitHub
parent 8d87a75fd6
commit 8ad01240a4
18 changed files with 1402 additions and 1136 deletions

View File

@@ -47,6 +47,17 @@ var _ = Describe("Commands", func() {
Expect(stats.IdleConns).To(Equal(uint32(1)))
})
It("should hello", func() {
cmds, err := client.Pipelined(ctx, func(pipe redis.Pipeliner) error {
pipe.Hello(ctx, 3, "", "", "")
return nil
})
Expect(err).NotTo(HaveOccurred())
m, err := cmds[0].(*redis.MapStringInterfaceCmd).Result()
Expect(err).NotTo(HaveOccurred())
Expect(m["proto"]).To(Equal(int64(3)))
})
It("should Echo", func() {
pipe := client.Pipeline()
echo := pipe.Echo(ctx, "hello")
@@ -182,10 +193,11 @@ var _ = Describe("Commands", func() {
It("should ConfigSet", func() {
configGet := client.ConfigGet(ctx, "maxmemory")
Expect(configGet.Err()).NotTo(HaveOccurred())
Expect(configGet.Val()).To(HaveLen(2))
Expect(configGet.Val()[0]).To(Equal("maxmemory"))
Expect(configGet.Val()).To(HaveLen(1))
_, ok := configGet.Val()["maxmemory"]
Expect(ok).To(BeTrue())
configSet := client.ConfigSet(ctx, "maxmemory", configGet.Val()[1].(string))
configSet := client.ConfigSet(ctx, "maxmemory", configGet.Val()["maxmemory"])
Expect(configSet.Err()).NotTo(HaveOccurred())
Expect(configSet.Val()).To(Equal("OK"))
})
@@ -1839,18 +1851,20 @@ var _ = Describe("Commands", func() {
err = client.HSet(ctx, "hash", "key2", "hello2").Err()
Expect(err).NotTo(HaveOccurred())
v := client.HRandField(ctx, "hash", 1, false)
v := client.HRandField(ctx, "hash", 1)
Expect(v.Err()).NotTo(HaveOccurred())
Expect(v.Val()).To(Or(Equal([]string{"key1"}), Equal([]string{"key2"})))
v = client.HRandField(ctx, "hash", 0, false)
v = client.HRandField(ctx, "hash", 0)
Expect(v.Err()).NotTo(HaveOccurred())
Expect(v.Val()).To(HaveLen(0))
var slice []string
err = client.HRandField(ctx, "hash", 1, true).ScanSlice(&slice)
kv, err := client.HRandFieldWithValues(ctx, "hash", 1).Result()
Expect(err).NotTo(HaveOccurred())
Expect(slice).To(Or(Equal([]string{"key1", "hello1"}), Equal([]string{"key2", "hello2"})))
Expect(kv).To(Or(
Equal([]redis.KeyValue{{Key: "key1", Value: "hello1"}}),
Equal([]redis.KeyValue{{Key: "key2", Value: "hello2"}}),
))
})
})
@@ -3919,18 +3933,20 @@ var _ = Describe("Commands", func() {
err = client.ZAdd(ctx, "zset", &redis.Z{Score: 2, Member: "two"}).Err()
Expect(err).NotTo(HaveOccurred())
v := client.ZRandMember(ctx, "zset", 1, false)
v := client.ZRandMember(ctx, "zset", 1)
Expect(v.Err()).NotTo(HaveOccurred())
Expect(v.Val()).To(Or(Equal([]string{"one"}), Equal([]string{"two"})))
v = client.ZRandMember(ctx, "zset", 0, false)
v = client.ZRandMember(ctx, "zset", 0)
Expect(v.Err()).NotTo(HaveOccurred())
Expect(v.Val()).To(HaveLen(0))
var slice []string
err = client.ZRandMember(ctx, "zset", 1, true).ScanSlice(&slice)
kv, err := client.ZRandMemberWithScores(ctx, "zset", 1).Result()
Expect(err).NotTo(HaveOccurred())
Expect(slice).To(Or(Equal([]string{"one", "1"}), Equal([]string{"two", "2"})))
Expect(kv).To(Or(
Equal([]redis.Z{{Member: "one", Score: 1}}),
Equal([]redis.Z{{Member: "two", Score: 2}}),
))
})
})
@@ -4675,7 +4691,7 @@ var _ = Describe("Commands", func() {
old := client.ConfigGet(ctx, key).Val()
client.ConfigSet(ctx, key, "0")
defer client.ConfigSet(ctx, key, old[1].(string))
defer client.ConfigSet(ctx, key, old[key])
err := rdb.Do(ctx, "slowlog", "reset").Err()
Expect(err).NotTo(HaveOccurred())