mirror of https://github.com/go-redis/redis.git
Support TimeSeries commands with RESP 2 protocol (#3184)
* Support Timeseries resp 2 * Change to resp 2 * Support Resp2 for TimeSeries commands
This commit is contained in:
parent
80c9f5bb77
commit
d1b4eaed41
60
command.go
60
command.go
|
@ -1403,27 +1403,63 @@ func (cmd *MapStringSliceInterfaceCmd) Val() map[string][]interface{} {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cmd *MapStringSliceInterfaceCmd) readReply(rd *proto.Reader) (err error) {
|
func (cmd *MapStringSliceInterfaceCmd) readReply(rd *proto.Reader) (err error) {
|
||||||
n, err := rd.ReadMapLen()
|
readType, err := rd.PeekReplyType()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
cmd.val = make(map[string][]interface{}, n)
|
|
||||||
for i := 0; i < n; i++ {
|
cmd.val = make(map[string][]interface{})
|
||||||
k, err := rd.ReadString()
|
|
||||||
|
if readType == proto.RespMap {
|
||||||
|
n, err := rd.ReadMapLen()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
nn, err := rd.ReadArrayLen()
|
for i := 0; i < n; i++ {
|
||||||
if err != nil {
|
k, err := rd.ReadString()
|
||||||
return err
|
|
||||||
}
|
|
||||||
cmd.val[k] = make([]interface{}, nn)
|
|
||||||
for j := 0; j < nn; j++ {
|
|
||||||
value, err := rd.ReadReply()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
cmd.val[k][j] = value
|
nn, err := rd.ReadArrayLen()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
cmd.val[k] = make([]interface{}, nn)
|
||||||
|
for j := 0; j < nn; j++ {
|
||||||
|
value, err := rd.ReadReply()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
cmd.val[k][j] = value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if readType == proto.RespArray {
|
||||||
|
// RESP2 response
|
||||||
|
n, err := rd.ReadArrayLen()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
for i := 0; i < n; i++ {
|
||||||
|
// Each entry in this array is itself an array with key details
|
||||||
|
itemLen, err := rd.ReadArrayLen()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
key, err := rd.ReadString()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
cmd.val[key] = make([]interface{}, 0, itemLen-1)
|
||||||
|
for j := 1; j < itemLen; j++ {
|
||||||
|
// Read the inner array for timestamp-value pairs
|
||||||
|
data, err := rd.ReadReply()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
cmd.val[key] = append(cmd.val[key], data)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue