Redis Keys Command

Redis key

The Redis KEYS command is used to find all keys that match the given pattern.

Syntax

The basic syntax of the redis KEYS command is as follows:

redis 127.0.0.1:6379> KEYS PATTERN

Available Versions

>= 1.0.0

Return Value

A list of keys matching the given pattern (Array).

Examples

First, create some keys and assign corresponding values:

redis 127.0.0.1:6379> SET example1 redis
OK
redis 127.0.0.1:6379> SET example2 mysql
OK
redis 127.0.0.1:6379> SET example3 mongodb
OK

Find keys that start with example:

redis 127.0.0.1:6379> KEYS example*
1) "example3"
2) "example1"
3) "example2"

To get all keys in redis, you can use*。

redis 127.0.0.1:6379> KEYS *
1) "example3"
2) "example1"
3) "example2"

Redis key

Other Extensions