Back to Redis

SCARD

content/commands/scard.md

latest1.0 KB
Original Source

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

Examples

{{% redis-cli %}} SADD myset "Hello" SADD myset "World" SCARD myset {{% /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="scard-return-info" tab1="RESP2" tab2="RESP3" >}}

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

-tab-sep-

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

{{< /multitabs >}}