Easy Tutorial
❮ Hashes Hmget Connection Quit ❯

Redis Zcard Command

Redis Sorted Set

The Redis Zcard command is used to calculate the number of elements in the set.

Syntax

The basic syntax of the redis Zcard command is as follows:

redis 127.0.0.1:6379> ZCARD KEY_NAME

Available Versions

= 1.2.0

Return Value

Returns the cardinality of the sorted set when the key exists and is of the sorted set type. Returns 0 when the key does not exist.

Example

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

Redis Sorted Set

❮ Hashes Hmget Connection Quit ❯