Redis ZCARD – How to get a size of the sorted set in redis datastore

2 months ago Lalit Bhagtani 0

In this tutorial, we will learn about how to get the size ( number of elements ) of a sorted set value stored at the key, by using a COMMAND – ZCARD in redis-cli. The syntax of redis ZCARD command is as follows :-

Syntax :-

redis host:post> ZCARD <key name>

Output :- 

(integer) value, representing the number of elements in the sorted set.
(integer) 0, if key does not exist.
Error, if key exist and value stored at the key is not a sorted set.

Example :-

Redis ZCARD

 

References :-

  1. ZCARD Command Docs

That’s all for how to get the size of a sorted set value stored in redis datastore. If you liked it, please share your thoughts in comments section and share it with others too.