杜智超
杜智超

Reputation: 637

redis how to limit the return number of KEYS command?

I get values with "KEYS p_*" command in redis.

But with "KEYS p_*" , if the redis has millions of keys,I will get too many values and bad performence.

So can I just get 100 values with "KEYS p_*" command?

Upvotes: 44

Views: 50482

Answers (1)

Liviu Costea
Liviu Costea

Reputation: 3784

SCAN is recommended for production, so you can use something like:

SCAN 0 COUNT 100 MATCH p_*

and keep getting the next page
for more details see the SCAN command:
http://redis.io/commands/scan

Upvotes: 74

Related Questions