Number of items in Redis set

countredisset

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…

Best Answer

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.