I know that in order to get all the list of all keys in Redis, I have to use KEYS *
, but is there a way to output all keys together with their values?
Few minutes of searching did not yield any result.
P.S. thank you very much for answers, but I am looking for a native solution. I can write a function that iterates through all the output of KEYS *
by myself.
There is no native way of doing this. The Redis command documentation contains no native commands for getting the key and value of multiple keys. The most native way of doing this would be to load a lua script into your redis using the SCRIPT LOAD command or the EVAL command.
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.
The Redis command documentation contains no native commands for getting the key and value of multiple keys.
The most native way of doing this would be to load a lua script into your redis using the SCRIPT LOAD
command or the EVAL
command.
A workaround would be to use some bash magic, like this:
echo 'keys YOURKEY*' | redis-cli | sed 's/^/get /' | redis-cli
This will output the data from all the keys which begin with YOURKEY
Note that the keys command is a blocking operation and should be used with care.
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