Redis SCARD – How to get a size of the 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 set value stored at the key, by using a COMMAND – SCARD in redis-cli. The syntax of redis SCARD command is as follows :-

Syntax :-

redis host:post> SCARD <key name>

Output :- 

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

Example :-


References :-

  1. SCARD Command Docs

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