-
Notifications
You must be signed in to change notification settings - Fork 76
KEYS
Returns keys matching pattern. This operation is used to iterate through the keyspace. The results are ordered by the key.
This operation is very fast because the keys are stored in a B-tree. In SummitDB it's OK to use this operation in production.
Please keep in mind that the default LIMIT is 100. This is to keep from having an accidental KEYS *
command on database with lots of keys. When specified, LIMIT is not constrained to 100 and can be any positive number.
- PIVOT value - The results will include all keys past value
- LIMIT limit - Limit the number of results. The default is 100
- DESC|ASC - Return the results in descending or ascending order
- WITHVALUES - Include both the key and value
- h?llo matches hello, hallo and hxllo
- h*llo matches hllo and heeeello
Array reply: list of keys matching pattern.
##Examples
Basic usage:
> MSET one 1 two 2 three 3 four 4
OK
> KEYS *o*
1) "one"
2) "two"
3) "four"
> KEYS t??
1) "two"
> KEYS * WITHVALUES
1) "four"
2) "4"
3) "one"
4) "1"
5) "three"
6) "3"
7) "two"
8) "2"
Iterating:
> MSET key:1 1 key:2 2 key:3 3 key:4 4 key:5 5 key:6 6
OK
> KEYS key:* LIMIT 3
1) "key:1"
2) "key:2"
3) "key:3"
> KEYS key:* PIVOT key:3 LIMIT 3
1) "key:4"
2) "key:5"
3) "key:6"
> KEYS key:* PIVOT key:6 LIMIT 3
(empty list or set)
APPEND, BITCOUNT, BITOP, BITPOS, DBSIZE, DECR, DECRBY, DEL, EXISTS, EXPIRE, EXPIREAT, FLUSHDB, GET, GETBIT, GETRANGE, GETSET, INCR, INCRBY, INCRBYFLOAT, KEYS, MGET, MSET, MSETNX, PDEL, PERSIST, PEXPIRE, PEXPIREAT, PTTL, RENAME, RENAMENX, SET, SETBIT, SETRANGE, STRLEN, TTL