XZSCAN key cursor [MATCH match] [COUNT count] [ASC|DESC]
(_ uhaha.Machine, args []string)
| 204 | |
| 205 | // scanTypeCursor is the resume point of one keyspace. |
| 206 | type 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. |
| 215 | type scanCursor struct { |
| 216 | types []scanTypeCursor |
| 217 | } |
| 218 | |
| 219 | func newScanCursor() scanCursor { |
| 220 | return scanCursor{types: make([]scanTypeCursor, len(scanTypeOrder))} |
| 221 | } |
| 222 | |
| 223 | func 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: |
nothing calls this directly
no outgoing calls
no test coverage detected