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?
The SCARD command returns the cardinality (i.e. number of items) of a Redis set.
The first command you can use to get the total number of keys in a Redis database is the DBSIZE command. This simple command should return the total number of keys in a selected database as an integer value. The above example command shows that there are 203 keys in the database at index 10.
Redis can handle up to 2^32 keys, and was tested in practice to handle at least 250 million keys per instance. Every hash, list, set, and sorted set, can hold 2^32 elements. In other words your limit is likely the available memory in your system.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With