Skip to main content

ZCARD

Syntax

ZCARD key

Time complexity: O(1)

ACL categories: @read, @sortedset, @fast

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

Return

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

Examples

dragonfly> ZADD myzset 1 "one"
(integer) 1
dragonfly> ZADD myzset 2 "two"
(integer) 1
dragonfly> ZCARD myzset
(integer) 2