w3resource

Redis Sorted Sets: ZCARD

ZCARD key

Redis ZCARD command is used to return the number of elements stored in the set at specified key.

Syntax:

ZCARD KEY_NAME

Available since

1.2.0.

Return Value

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

Return Value Type

Integer

Example: Redis ZCARD

127.0.0.1:6379> ZADD mycolorset 10 white 12 black 14 red 16 blue
(integer) 4
127.0.0.1:6379> ZADD mycolorset 18 green 20 orange 22 pink 24 yellow
(integer) 4
127.0.0.1:6379> ZCARD mycolorset
(integer) 8
127.0.0.1:6379>

Previous: ZADD
Next: ZCOUNT



Follow us on Facebook and Twitter for latest update.