Keys returns all keys matching pattern
(ctx *Context, txn *db.Transaction)
| 246 | |
| 247 | // Keys returns all keys matching pattern |
| 248 | func Keys(ctx *Context, txn *db.Transaction) (OnCommit, error) { |
| 249 | list := make([][]byte, 0) |
| 250 | pattern := []byte(ctx.Args[0]) |
| 251 | all := (pattern[0] == '*' && len(pattern) == 1) |
| 252 | prefix := globMatchPrefix(pattern) |
| 253 | |
| 254 | kv := txn.Kv() |
| 255 | f := func(key []byte) bool { |
| 256 | if all || globMatch(pattern, key, false) { |
| 257 | list = append(list, key) |
| 258 | } |
| 259 | return true |
| 260 | } |
| 261 | |
| 262 | if err := kv.Keys(prefix, f); err != nil { |
| 263 | return nil, errors.New("ERR " + err.Error()) |
| 264 | } |
| 265 | return BytesArray(ctx.Out, list), nil |
| 266 | } |
| 267 | |
| 268 | // Scan incrementally iterates the key space |
| 269 | func Scan(ctx *Context, txn *db.Transaction) (OnCommit, error) { |
nothing calls this directly
no test coverage detected