redis ZCARD command
Translation results:
card
redis ZCARD commandsyntax
Function: Returns the cardinality of the ordered set key.
Syntax: ZCARD key
Available versions: >= 1.2.0
Time complexity: O(1)
Return: When key exists and is an ordered set type, return the cardinality of the ordered set. When key does not exist, return 0.
redis ZCARD commandexample
redis > ZADD salary 2000 tom # 添加一个成员 (integer) 1 redis > ZCARD salary (integer) 1 redis > ZADD salary 5000 jack # 再添加一个成员 (integer) 1 redis > ZCARD salary (integer) 2 redis > EXISTS non_exists_key # 对不存在的 key 进行 ZCARD 操作 (integer) 0 redis > ZCARD non_exists_key (integer) 0