Source File
iterator.go
Belonging Package
github.com/redis/go-redis/v9
package redisimport ()// ScanIterator is used to incrementally iterate over a collection of elements.type ScanIterator struct {cmd *ScanCmdpos int}// Err returns the last iterator error, if any.func ( *ScanIterator) () error {return .cmd.Err()}// Next advances the cursor and returns true if more values can be read.func ( *ScanIterator) ( context.Context) bool {// Instantly return on errors.if .cmd.Err() != nil {return false}// Advance cursor, check if we are still within range.if .pos < len(.cmd.page) {.pos++return true}for {// Return if there is no more data to fetch.if .cmd.cursor == 0 {return false}// Fetch next page.switch .cmd.args[0] {case "scan", "qscan":.cmd.args[1] = .cmd.cursordefault:.cmd.args[2] = .cmd.cursor}:= .cmd.process(, .cmd)if != nil {return false}.pos = 1// Redis can occasionally return empty page.if len(.cmd.page) > 0 {return true}}}// Val returns the key/field at the current cursor position.func ( *ScanIterator) () string {var stringif .cmd.Err() == nil && .pos > 0 && .pos <= len(.cmd.page) {= .cmd.page[.pos-1]}return}
![]() |
The pages are generated with Golds v0.8.2. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |