ZCARD key

Available since 1.2.0.

Time complexity: O(1)

Returns the sorted set cardinality (number of elements) of the sorted set stored at key.

*Return value

Integer reply: the cardinality (number of elements) of the sorted set, or 0 if key does not exist.

*Examples

redis> ZADD myzset 1 "one"

  1. (integer) 1

redis> ZADD myzset 2 "two"

  1. (integer) 1

redis> ZCARD myzset

  1. (integer) 2
redis>