X-Git-Url: https://git.saurik.com/redis.git/blobdiff_plain/02fdd5ab4c8691156c150bc3948cbebbe8b208ad..49128f0b9da725de992e427fa341a837bcc2991b:/doc/KeysCommand.html diff --git a/doc/KeysCommand.html b/doc/KeysCommand.html index 98718fc0..f1a6e070 100644 --- a/doc/KeysCommand.html +++ b/doc/KeysCommand.html @@ -16,7 +16,7 @@
-KeysCommand: Contents
  KEYS _pattern_
    Return value
    See also +KeysCommand: Contents
  KEYS _pattern_
    Return value

KeysCommand

@@ -26,13 +26,13 @@
-

KEYS _pattern_

+ #sidebar GenericCommandsSidebar

KEYS _pattern_

Time complexity: O(n) (with n being the number of keys in the DB, and assuming keys and pattern of limited length)
Returns all the keys matching the glob-style pattern asspace separated strings. For example if you have in thedatabase the keys "foo" and "foobar" the command "KEYS foo*"will return "foo foobar".
-
Note that while the time complexity for this operation is O(n)the constant times are pretty low. For example Redis runningon an entry level laptop can scan a 1 million keys databasein 40 milliseconds. Still it's better to consider this one ofthe slow commands that may ruin the DB performance if not usedwith care.
+
Note that while the time complexity for this operation is O(n)the constant times are pretty low. For example Redis runningon an entry level laptop can scan a 1 million keys databasein 40 milliseconds. Still it's better to consider this one of +
the slow commands that may ruin the DB performance if not usedwith care*.
+
In other words this command is intended only for debugging and *special* operations like creating a script to change the DB schema. Don't use it in your normal code. Use Redis Sets in order to group together a subset of objects.
Glob style patterns examples: -
  • h?llo will match hello hallo hhllo
  • hllo will match hllo heeeello -
    * haello will match hello and hallo, but not hillo
    Use \ to escape special chars if you want to match them verbatim.

    Return value

    Bulk reply, specifically a string in the form of space separated list of keys. Note that most client libraries will return an Array of keys and not a single string with space separated keys (that is, split by " " is performed in the client library usually).

    See also

    -
    * RANDOMKEY to get the name of a randomly selected key in O(1).
+
* h?llo will match hello hallo hhllo* h*llo will match hllo heeeello* h[ae]llo will match hello and hallo, but not hillo
Use \ to escape special chars if you want to match them verbatim.

Return value

Bulk reply, specifically a string in the form of space separated list of keys. Note that most client libraries will return an Array of keys and not a single string with space separated keys (that is, split by " " is performed in the client library usually).