Back to Redis

ZCARD

content/commands/zcard.md

latest1.1 KB
Original Source

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

Examples

{{% redis-cli %}} ZADD myzset 1 "one" ZADD myzset 2 "two" ZCARD myzset {{% /redis-cli %}}

Redis Software and Redis Cloud compatibility

| Redis Software | Redis Cloud | <span style="min-width: 9em; display: table-cell">Notes</span> | |:----------------------|:-----------------|:------| | <span title="Supported">✅ Standard</span> <span title="Supported"><nobr>✅ Active-Active</nobr></span> | <span title="Supported">✅ Standard</span> <span title="Supported"><nobr>✅ Active-Active</nobr></span> | |

Return information

{{< multitabs id="zcard-return-info" tab1="RESP2" tab2="RESP3" >}}

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

-tab-sep-

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

{{< /multitabs >}}