Redis How to limit the return number of a KEYS command?

I get values โ€‹โ€‹with the "KEYS p_ *" command in redis.

But with "KEYS p_ *", if redis has millions of keys, I will get too many values โ€‹โ€‹and poor performance.

So, can I just get 100 values โ€‹โ€‹with the "KEYS p_ *" command?

+6
source share
1 answer

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

SCAN 0 COUNT 100 MATCH p_* 

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

+11
source

Source: https://habr.com/ru/post/988425/


All Articles