Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Show all keys in redis - in one line

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.

like image 431
Michael B Avatar asked Aug 25 '12 04:08

Michael B


People also ask

How do I view Redis data?

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.

How do I view the contents of Redis cache?

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.

How can I get total number of keys in Redis?

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.

Which command is used to obtain all the keys in a database in Redis?

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).


1 Answers

You need to do

redis-cli keys '*' 

to avoid your shell from expanding * into a list of filenames.

like image 130
nneonneo Avatar answered Sep 22 '22 01:09

nneonneo