Here’s how you can use the KEYS
command in Redis Commander:
- Command:
KEYS pattern
- Function: The
KEYS
command is used to find all keys matching a specific pattern. This can be especially helpful when you want to locate keys with a common prefix, suffix, or specific pattern in their names. In Redis Commander, you can use this command to search for keys that match the pattern you specify. - Example:
- Pattern:
example:*
- Command:
KEYS example:*
- Output: A list of all keys matching the pattern, for example:
["example:string", "example:list", "example:set"]
.
- Pattern:
Redis Commander simplifies browsing and searching for keys:
- You can directly use the search bar in Redis Commander to filter and display keys matching a specific pattern.
- Redis Commander will show all matched keys in the sidebar, allowing you to explore each key and its type-specific functions without having to manually enter the
KEYS
command.
Using KEYS
with patterns is a powerful way to locate keys by name convention, especially when managing a large set of data in Redis.
- Command:
GET key
- Function: This command is used to retrieve the value of a key of type string. In Redis Commander, when you select a key of type
string
, Redis Commander will display the value of the key directly on the dashboard. - Example**:
- Key:
example:string
- Command:
GET example:string
- Output:
“Hello, Redis!”
- Command:
LINDEX key index
- Function: The
LINDEX
command is used to retrieve elements from a list at a specific position (by index). In Redis Commander, you can view list elements, and by selecting a key of typelist
, you can use this function to retrieve a specific element based on its index. - Example**:
- Key:
example:list
- Command:
LINDEX example:list 0
- Output: The element at index 0 of the list.
- Command:
SMEMBERS key
- Function:
SMEMBERS
is used to retrieve all members of a set. Redis Commander will display all elements of a key of typeset
automatically after you select the key in the dashboard. - Example**:
- Key:
example:set
- Command:
SMEMBERS example:set
- Output: All members of the set, for example
[“apple”, “banana”, “orange”]
.
- Command:
HGETALL key
- Function:
HGETALL
is used to retrieve all fields and values from a key of typehash
. In Redis Commander, when you select a key of hash type, all the associated fields and values will be displayed automatically using this command. - Example:
- Key:
example:hash
- Command:
HGETALL example:hash
- Output:
{“field1”: “value1”, ‘field2’: “value2"}
In Redis Commander, these components work automatically according to the key type:
- When you select a key of type string, Redis Commander will use
GET
to display the string value. - When you select a key of type list, Redis Commander will display a list, and you can select elements by index using
LINDEX
. - For set, Redis Commander will display all members of the set with the
SMEMBERS
command. - For hash, Redis Commander will utilize
HGETALL
to display all field and value pairs.
Redis Commander makes it easy to explore data without manually typing commands, as it recognizes key types and automatically displays relevant results based on those Redis commands. commands, as it recognizes key types and automatically displays relevant results based on those Redis commands.