mirror of https://github.com/go-redis/redis.git
Merge pull request #2356 from go-redis/fix/cursor-uint64
fix: read cursor as uint64
This commit is contained in:
commit
e314cd9846
|
@ -2694,11 +2694,11 @@ func (cmd *ScanCmd) readReply(rd *proto.Reader) error {
|
|||
return err
|
||||
}
|
||||
|
||||
cursor, err := rd.ReadInt()
|
||||
cursor, err := rd.ReadUint()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
cmd.cursor = uint64(cursor)
|
||||
cmd.cursor = cursor
|
||||
|
||||
n, err := rd.ReadArrayLen()
|
||||
if err != nil {
|
||||
|
|
|
@ -319,6 +319,33 @@ func (r *Reader) ReadInt() (int64, error) {
|
|||
return 0, fmt.Errorf("redis: can't parse int reply: %.100q", line)
|
||||
}
|
||||
|
||||
func (r *Reader) ReadUint() (uint64, error) {
|
||||
line, err := r.ReadLine()
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
switch line[0] {
|
||||
case RespInt, RespStatus:
|
||||
return util.ParseUint(line[1:], 10, 64)
|
||||
case RespString:
|
||||
s, err := r.readStringReply(line)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return util.ParseUint([]byte(s), 10, 64)
|
||||
case RespBigInt:
|
||||
b, err := r.readBigInt(line)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
if !b.IsUint64() {
|
||||
return 0, fmt.Errorf("bigInt(%s) value out of range", b.String())
|
||||
}
|
||||
return b.Uint64(), nil
|
||||
}
|
||||
return 0, fmt.Errorf("redis: can't parse uint reply: %.100q", line)
|
||||
}
|
||||
|
||||
func (r *Reader) ReadFloat() (float64, error) {
|
||||
line, err := r.ReadLine()
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue