KEYS

Since 1.1.0Keys

Syntax

KEYS pattern
  • ACL categories: @dangerous, @generic, @keyspace, @read, @slow
  • Arity: 2

Returns every key of the current database that matches a glob-style pattern.

PatternMatches
*any characters
?one character
[abc], [a-z]one of those characters
[^a]any character but a
\*a literal *

KEYS goes through the whole database in one call, so on a large one it is slow. Use SCAN in applications.

Reply

  • An array of key names, in no particular order.

Examples

> MSET user:1 a user:2 b order:1 c
OK
> KEYS user:*
1) "user:2"
2) "user:1"
> KEYS [uo]*:1
1) "order:1"
2) "user:1"