KEYS pattern
Returns all the keys matching the glob-style pattern as space-separated strings.
For example, if you have in the database the keys "foo" and "foobar" the command "KEYS foo*" will return "foo foobar".
TIME COMPLEXITY: O(n) (with n being the number of keys in the DB, and assuming keys and pattern of limited length).
Note: Use \ to escape special chars if you want to match them verbatim.
RETURN VALUE: Bulk reply, specifically a string in the form of a space-separated list of keys.
Syntax:
KEYS PATTERN
Example 1: When the keys with patterns are present
redis:6379> SET hello 178"OK"redis:6379> SET heeello 190"OK"redis:6379> SET hillo 109"OK"redis:6379> KEYS h*llo1) "hello"2) "heeello"3) "hillo"
Output
1) "hello"
2) "heeello"
3) "hillo"
Example 2: When the keys with the pattern are not present
redis:6379> KEYS h*llo(empty array)
Output
empty array
No comments:
Post a Comment