30

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.

Community
  • 1
  • 1
Michael B
  • 1,743
  • 4
  • 21
  • 35

1 Answers1

50

You need to do

redis-cli keys '*'

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

nneonneo
  • 171,345
  • 36
  • 312
  • 383
  • Such approach has a problem. KEYS block Redis (mention [here](http://redis.io/commands/scan)). So, it can significant decrease performance of Redis if it has a lot of keys. Instead of this command better to use [SCAN](http://redis.io/commands/scan) command or specialized tools like [Keylord](http://protonail.com/products/keylord) for manage Redis databases (it using SCAN command for load keys). – Maxim Apr 28 '15 at 08:47