1
0
mirror of https://github.com/redis/go-redis.git synced 2025-07-28 06:42:00 +03:00

fix: firstKeyPos cmdSlot (#1502)

* fix(xread):cmdSlot

Co-authored-by: zhangxinjian <zhangxinjian@crop.netease.com>
This commit is contained in:
jamsonzan
2020-09-23 15:22:11 +08:00
committed by GitHub
parent e6caec210d
commit c89b69131d
2 changed files with 29 additions and 1 deletions

View File

@ -18,6 +18,8 @@ type Cmder interface {
Args() []interface{}
String() string
stringArg(int) string
firstKeyPos() int
addKeyPos(int)
readTimeout() *time.Duration
readReply(rd *proto.Reader) error
@ -73,6 +75,9 @@ func cmdFirstKeyPos(cmd Cmder, info *CommandInfo) int {
}
}
if pos := cmd.firstKeyPos(); pos != 0 {
return pos
}
if info == nil {
return 0
}
@ -106,6 +111,7 @@ type baseCmd struct {
ctx context.Context
args []interface{}
err error
keyPos int
_readTimeout *time.Duration
}
@ -147,6 +153,14 @@ func (cmd *baseCmd) stringArg(pos int) string {
return s
}
func (cmd *baseCmd) firstKeyPos() int {
return cmd.keyPos
}
func (cmd *baseCmd) addKeyPos(offset int) {
cmd.keyPos += offset
}
func (cmd *baseCmd) SetErr(e error) {
cmd.err = e
}