Latest web development tutorials

Redis Scard command

Redis set (Set)

Redis Scard command returns the number of elements in the collection.

grammar

redis Scard basic command syntax is as follows:

redis 127.0.0.1:6379> SCARD KEY_NAME 

Available versions

> = 1.0.0

return value

The number of collections. When the set key does not exist, 0 is returned.

Examples

redis 127.0.0.1:6379> SADD myset "hello"
(integer) 1
redis 127.0.0.1:6379> SADD myset "foo"
(integer) 1
redis 127.0.0.1:6379> SADD myset "hello"
(integer) 0
redis 127.0.0.1:6379> SCARD myset
(integer) 2

Redis set (Set)