I need to see all available keys in Redis. This question:
Redis command to get all available keys?
Adequately covers the case where I run redis-cli
with no arguments, then type keys *
.
However, how do I get all keys with a single command?
redis-cli keys *
returns:
(error) ERR wrong number of arguments for 'keys' command
Even though there are keys set, which checks out if you use the two-command solution.
A Redis server has 16 databases by default. You can check the actual number by running redis-cli config get databases. In interactive mode, the database number is displayed in the prompt within square braces. For example, 127.0. 0.1:6379[13] shows that the 13th database is in use.
By clicking on a Redis key name, all its contents will open in a new editor tab. With a collection type Redis key, clicking on it will reveal the individual elements under the key name. Clicking the individual element will display its contents in a new editor tab.
The first command you can use to get the total number of keys in a Redis database is the DBSIZE command. This simple command should return the total number of keys in a selected database as an integer value. The above example command shows that there are 203 keys in the database at index 10.
The Redis KEYS command returns all the keys in the database that match a pattern (or all the keys in the key space). Similar commands for fetching all the fields stored in a hash is HGETALL and for all fetching the members of a SMEMBERS. The keys in Redis themselves are stored in a dictionary (aka a hash table).
You need to do
redis-cli keys '*'
to avoid your shell from expanding *
into a list of filenames.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With