SCARD key

Available since 1.0.0.

Time complexity: O(1)

Returns the set cardinality (number of elements) of the set stored at key.

*Return value

Integer reply: the cardinality (number of elements) of the set, or 0 if key does not exist.

*Examples

redis> SADD myset "Hello"

  1. (integer) 1

redis> SADD myset "World"

  1. (integer) 1

redis> SCARD myset

  1. (integer) 2
redis>