Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Redis Keys Command

Redis Keys Command

Redis Key

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

Syntax

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



redis 127.0.0.1:6379> KEYS PATTERN

Available Version

= 1.0.0

Return Value

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

Example

First, create some keys and assign corresponding values:



redis 127.0.0.1:6379> SET runoob1 redis

OK

redis 127.0.0.1:6379> SET runoob2 mysql

OK

redis 127.0.0.1:6379> SET runoob3 mongodb

OK

Find keys starting with runoob:



redis 127.0.0.1:6379> KEYS runoob*

1) "runoob3"

2) "runoob1"

3) "runoob2"

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



redis 127.0.0.1:6379> KEYS *

1) "runoob3"

2) "runoob1"

3) "runoob2"

Redis Key