mirror of
https://github.com/redis/go-redis.git
synced 2025-04-17 20:17:02 +03:00
fix: read cursor as uint64
This commit is contained in:
parent
3dc5e40445
commit
b88bd93662
@ -2693,11 +2693,11 @@ func (cmd *ScanCmd) readReply(rd *proto.Reader) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
cursor, err := rd.ReadInt()
|
cursor, err := rd.ReadUint()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
cmd.cursor = uint64(cursor)
|
cmd.cursor = cursor
|
||||||
|
|
||||||
n, err := rd.ReadArrayLen()
|
n, err := rd.ReadArrayLen()
|
||||||
if err != nil {
|
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)
|
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) {
|
func (r *Reader) ReadFloat() (float64, error) {
|
||||||
line, err := r.ReadLine()
|
line, err := r.ReadLine()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user