mirror of
https://github.com/redis/go-redis.git
synced 2025-07-29 17:41:15 +03:00
fix iterator across empty pages
This commit is contained in:
39
iterator.go
39
iterator.go
@ -46,25 +46,30 @@ func (it *ScanIterator) Next() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// Return if there is more data to fetch.
|
||||
if it.ScanCmd.cursor == 0 {
|
||||
return false
|
||||
}
|
||||
for {
|
||||
// Return if there is more data to fetch.
|
||||
if it.ScanCmd.cursor == 0 {
|
||||
return false
|
||||
}
|
||||
|
||||
// Fetch next page.
|
||||
if it.ScanCmd._args[0] == "scan" {
|
||||
it.ScanCmd._args[1] = it.ScanCmd.cursor
|
||||
} else {
|
||||
it.ScanCmd._args[2] = it.ScanCmd.cursor
|
||||
}
|
||||
it.ScanCmd.reset()
|
||||
it.client.process(it.ScanCmd)
|
||||
if it.ScanCmd.Err() != nil {
|
||||
return false
|
||||
}
|
||||
// Fetch next page.
|
||||
if it.ScanCmd._args[0] == "scan" {
|
||||
it.ScanCmd._args[1] = it.ScanCmd.cursor
|
||||
} else {
|
||||
it.ScanCmd._args[2] = it.ScanCmd.cursor
|
||||
}
|
||||
it.ScanCmd.reset()
|
||||
it.client.process(it.ScanCmd)
|
||||
if it.ScanCmd.Err() != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
it.pos = 1
|
||||
return len(it.ScanCmd.page) > 0
|
||||
it.pos = 1
|
||||
if len(it.ScanCmd.page) > 0 {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// Val returns the key/field at the current cursor position.
|
||||
|
Reference in New Issue
Block a user