Easy Tutorial
❮ Redis Hashes Hashes Hincrbyfloat ❯

Redis Keys Command

Redis Key

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

Syntax

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

redis 127.0.0.1:6379> KEYS PATTERN

Available Versions

= 1.0.0

Return Value

A list (Array) of keys that match the given pattern.

Example

First, create some keys and assign corresponding values:

redis 127.0.0.1:6379> SET tutorialpro1 redis
OK
redis 127.0.0.1:6379> SET tutorialpro2 mysql
OK
redis 127.0.0.1:6379> SET tutorialpro3 mongodb
OK

Find keys that start with "tutorialpro":

redis 127.0.0.1:6379> KEYS tutorialpro*
1) "tutorialpro3"
2) "tutorialpro1"
3) "tutorialpro2"

To get all keys in redis, use *:

redis 127.0.0.1:6379> KEYS *
1) "tutorialpro3"
2) "tutorialpro1"
3) "tutorialpro2"

Redis Key

❮ Redis Hashes Hashes Hincrbyfloat ❯