ZCARD · Valkey

ZCARD

Returns the number of members in a sorted set.

Usage

ZCARD key

Description

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

Reply

Integer reply: the cardinality (number of members) of the sorted set, or 0 if the key doesn’t exist.

Complexity

O(1)

ACL Categories

@fast @read @sortedset

Examples

127.0.0.1:6379> ZADD myzset 1 "one"
(integer) 1
127.0.0.1:6379> ZADD myzset 2 "two"
(integer) 1
127.0.0.1:6379> ZCARD myzset
(integer) 2

History

See also

BZMPOP, BZPOPMAX, BZPOPMIN, ZADD, ZCOUNT, ZDIFF, ZDIFFSTORE, ZINCRBY, ZINTER, ZINTERCARD, ZINTERSTORE, ZLEXCOUNT, ZMPOP, ZMSCORE, ZPOPMAX, ZPOPMIN, ZRANDMEMBER, ZRANGE, ZRANGESTORE, ZRANK, ZREM, ZREMRANGEBYLEX, ZREMRANGEBYRANK, ZREMRANGEBYSCORE, ZREVRANK, ZSCAN, ZSCORE, ZUNION, ZUNIONSTORE.