1

Is it possible to get all the keys that start with a digit(e.g. 12.2323.MKSUID)? the KEYS command is supposed to support patterns but what kind of patterns/regex flavour ? I've tried KEYS \d with no result.

3 Answers3

4

The KEYS command supports glob style patterns. To match keys that start with a digit, you can use the pattern:

KEYS [0-9]*

As Itamar notes, be careful using KEYS with a pattern match against a live system, it can severely impact performance.

More details and examples can be found in the description of KEYS on redis.io

Itamar Haber
  • 47,336
  • 7
  • 91
  • 117
Tague Griffith
  • 3,963
  • 2
  • 20
  • 24
4

This question has some good info. Like the comment suggested, better to use scan:

SCAN 0 MATCH "[0-9]*"
Community
  • 1
  • 1
systemjack
  • 2,815
  • 17
  • 26
1

For getting keys that starts with digit.

KEYS [0-9]*

Sahil Gulati
  • 15,028
  • 4
  • 24
  • 42
  • 1
    For the sake of future readers: while this answer is 100% correct - KEYS should be avoided in real world situations, and you should use SCAN instead. – Not_a_Golfer Feb 21 '17 at 20:40