We're planning to use MGET for one of our Systems. During benchmarking, we were able to retrieve values for 1 Million Keys in one MGET call in lettuce and were quite surprised.
What I've been trying to find are the limitations of MGET. Specifically,
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.
Redis MGET command is used to get the values of all specified keys. For every key that does not hold a string value or does not exist, the special value nil is returned.
The maximum allowed key size is 512 MB.
Is there any limit to number of Keys that can be retrieved in one MGET call?
Theoretically, the limit is the max value for int: 0x7FFFFFFF. However, in practice, you CANNOT have so many keys in a single Redis instance (it costs too much memory).
Is there any limit to size of data that gets returned by a single MGET call?
Theoretically, NO limit. However, in practice, Redis saves the returned values in memory before sending to client, so if you try to MGET
too many keys, you'll get OOM problem.
In a word, it's a bad idea to MGET
too many keys from Redis: it costs too much memory, and blocks Redis for a long time.
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