Redis: Get All Keys – Redis-CLI

There are two ways to get all keys from the all databases in Redis.

The first way is to list keys using --scan option and the second one is to get all keys using the KEYS command.

Note that the first way of getting all keys is preferable as it doesn’t require the client to load all the keys into memory despite of the KEYS command.

Use KEYS command only when the key space is reasonably sized.

Cool Tip: Delete all keys from the all databases in Redis! Read more →

Get All Keys In Redis

Get all keys using the --scan option:

$ redis-cli --scan --pattern *

List all keys using the KEYS command:

$ redis-cli KEYS *