ZCARD
Synopsis
ZCARD key
This command returns the number of members
in the sorted set at key
. If key
does not exist, 0 is returned.
- If
key
is associated with non sorted-set data, an error is returned.
Return value
The cardinality of the sorted set.
Examples
You can do this as shown below.
$ ZADD z_key 1.0 v1 2.0 v2
(integer) 2
$ ZADD z_key 3.0 v2
(integer) 0
$ ZCARD z_key
(integer) 2
$ ZCARD ts_key
(integer) 0