1
0
mirror of https://github.com/redis/go-redis.git synced 2025-07-29 17:41:15 +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

@ -9,23 +9,63 @@ import (
)
func BenchmarkReader_ParseReply_Status(b *testing.B) {
benchmarkParseReply(b, "+OK\r\n", nil, false)
benchmarkParseReply(b, "+OK\r\n", false)
}
func BenchmarkReader_ParseReply_Int(b *testing.B) {
benchmarkParseReply(b, ":1\r\n", nil, false)
benchmarkParseReply(b, ":1\r\n", false)
}
func BenchmarkReader_ParseReply_Float(b *testing.B) {
benchmarkParseReply(b, ",123.456\r\n", false)
}
func BenchmarkReader_ParseReply_Bool(b *testing.B) {
benchmarkParseReply(b, "#t\r\n", false)
}
func BenchmarkReader_ParseReply_BigInt(b *testing.B) {
benchmarkParseReply(b, "(3492890328409238509324850943850943825024385\r\n", false)
}
func BenchmarkReader_ParseReply_Error(b *testing.B) {
benchmarkParseReply(b, "-Error message\r\n", nil, true)
benchmarkParseReply(b, "-Error message\r\n", true)
}
func BenchmarkReader_ParseReply_Nil(b *testing.B) {
benchmarkParseReply(b, "_\r\n", true)
}
func BenchmarkReader_ParseReply_BlobError(b *testing.B) {
benchmarkParseReply(b, "!21\r\nSYNTAX invalid syntax", true)
}
func BenchmarkReader_ParseReply_String(b *testing.B) {
benchmarkParseReply(b, "$5\r\nhello\r\n", nil, false)
benchmarkParseReply(b, "$5\r\nhello\r\n", false)
}
func BenchmarkReader_ParseReply_Verb(b *testing.B) {
benchmarkParseReply(b, "$9\r\ntxt:hello\r\n", false)
}
func BenchmarkReader_ParseReply_Slice(b *testing.B) {
benchmarkParseReply(b, "*2\r\n$5\r\nhello\r\n$5\r\nworld\r\n", multiBulkParse, false)
benchmarkParseReply(b, "*2\r\n$5\r\nhello\r\n$5\r\nworld\r\n", false)
}
func BenchmarkReader_ParseReply_Set(b *testing.B) {
benchmarkParseReply(b, "~2\r\n$5\r\nhello\r\n$5\r\nworld\r\n", false)
}
func BenchmarkReader_ParseReply_Push(b *testing.B) {
benchmarkParseReply(b, ">2\r\n$5\r\nhello\r\n$5\r\nworld\r\n", false)
}
func BenchmarkReader_ParseReply_Map(b *testing.B) {
benchmarkParseReply(b, "%2\r\n$5\r\nhello\r\n$5\r\nworld\r\n+key\r\n+value\r\n", false)
}
func BenchmarkReader_ParseReply_Attr(b *testing.B) {
benchmarkParseReply(b, "%1\r\n+key\r\n+value\r\n+hello\r\n", false)
}
func TestReader_ReadLine(t *testing.T) {
@ -43,7 +83,7 @@ func TestReader_ReadLine(t *testing.T) {
}
}
func benchmarkParseReply(b *testing.B, reply string, m proto.MultiBulkParse, wanterr bool) {
func benchmarkParseReply(b *testing.B, reply string, wanterr bool) {
buf := new(bytes.Buffer)
for i := 0; i < b.N; i++ {
buf.WriteString(reply)
@ -52,21 +92,9 @@ func benchmarkParseReply(b *testing.B, reply string, m proto.MultiBulkParse, wan
b.ResetTimer()
for i := 0; i < b.N; i++ {
_, err := p.ReadReply(m)
_, err := p.ReadReply()
if !wanterr && err != nil {
b.Fatal(err)
}
}
}
func multiBulkParse(p *proto.Reader, n int64) (interface{}, error) {
vv := make([]interface{}, 0, n)
for i := int64(0); i < n; i++ {
v, err := p.ReadReply(multiBulkParse)
if err != nil {
return nil, err
}
vv = append(vv, v)
}
return vv, nil
}