KEYS
Syntax
KEYS pattern
Time complexity: O(N) with N being the number of keys in the database, under the assumption that the key names in the database and the given pattern have limited length.
ACL categories: @keyspace, @read, @slow, @dangerous
Returns all keys matching pattern
.
While the time complexity for this operation is O(N), the constant times are fairly low.
Supported glob-style patterns:
h?llo
matcheshello
,hallo
andhxllo
h*llo
matcheshllo
andheeeello
h[ae]llo
matcheshello
andhallo,
but nothillo
h[^e]llo
matcheshallo
,hbllo
, ... but nothello
h[a-b]llo
matcheshallo
andhbllo
Use \
to escape special characters if you want to match them verbatim.
Return
Array reply: list of keys matching pattern
.
Number of elements returned:
Dragonfly protects itself from an overwhelming number of returned keys by imposing a limit on the quantity. To modify this limit, update the value of the "keys_output_limit" flag. Please refer to Dragonfly configuration for more information how to change dragonfly flag values.
Examples
dragonfly> MSET firstname Jack lastname Stuntman age 35
OK
dragonfly> KEYS *name*
1) "lastname"
2) "firstname"
dragonfly> KEYS a??
1) "age"
dragonfly> KEYS *
1) "lastname"
2) "age"
3) "firstname"