Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Redis Zcard Command

Redis Zcard Command

Redis Sorted Set

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

Syntax

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



redis 127.0.0.1:6379> ZCARD KEY_NAME

Available Version

= 1.2.0

Return Value

Returns the cardinality of the sorted set when key exists and is of sorted set type. Returns 0 when 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