What's the easiest way to getting the number (count) of items in Redis set? Preferably without the need to dump whole set and count the lines... So far, I have found only BITCOUNT, which I have not found that useful...
Number of items in Redis set
The SCARD command returns the cardinality (i.e. number of items) of a Redis set.
http://redis.io/commands/scard
There is a similar command (ZCARD) for sorted sets.
Also if you have a sorted set, you can use the ZCOUNT
command to get the number of elements in the sorted set at key with a score between min and max.
Example:
ZCOUNT myzset 2 15
return count of elements with score >= 2 and <= 15
© 2022 - 2024 — McMap. All rights reserved.
llen
. – Squally