MCPcopy Create free account
hub / github.com/IceFireDB/IceFireDB / cmdXZSCAN

Method cmdXZSCAN

scan.go:206–239  ·  view source on GitHub ↗

XZSCAN key cursor [MATCH match] [COUNT count] [ASC|DESC]

(_ uhaha.Machine, args []string)

Source from the content-addressed store, hash-verified

204
205// scanTypeCursor is the resume point of one keyspace.
206type scanTypeCursor struct {
207 started bool
208 exhausted bool
209 last []byte
210}
211
212// scanCursor carries one sub-cursor per keyspace. The engine keeps every type in
213// its own keyspace with no global key order, so one Redis cursor has to gather
214// all of them; the encoding is opaque to clients.
215type scanCursor struct {
216 types []scanTypeCursor
217}
218
219func newScanCursor() scanCursor {
220 return scanCursor{types: make([]scanTypeCursor, len(scanTypeOrder))}
221}
222
223func parseScanCursor(s string) (scanCursor, error) {
224 c := newScanCursor()
225 if s == "" || s == "0" {
226 return c, nil
227 }
228 raw, err := base64.RawURLEncoding.DecodeString(s)
229 if err != nil {
230 return c, fmt.Errorf("ERR invalid cursor")
231 }
232 fields := strings.Split(string(raw), "|")
233 if len(fields) != len(c.types) {
234 return c, fmt.Errorf("ERR invalid cursor")
235 }
236 for i, f := range fields {
237 switch f {
238 case "":
239 // not started yet
240 case "-":
241 c.types[i].started, c.types[i].exhausted = true, true
242 default:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected