scard.3valkey - Man Page

Returns the number of members in a set.

Synopsis

SCARD key

Description

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

Reply

Resp2

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

Resp3

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

Complexity

O(1)

Acl Categories

@fast @read @set

History

Examples

127.0.0.1:6379> SADD myset "Hello"
(integer) 1
127.0.0.1:6379> SADD myset "World"
(integer) 1
127.0.0.1:6379> SCARD myset
(integer) 2

See Also

sadd(3valkey), sdiff(3valkey), sdiffstore(3valkey), sinter(3valkey), sintercard(3valkey), sinterstore(3valkey), sismember(3valkey), smembers(3valkey), smismember(3valkey), smove(3valkey), spop(3valkey), srandmember(3valkey), srem(3valkey), sscan(3valkey), sunion(3valkey), sunionstore(3valkey)

Info

2024-09-23 8.0.0 Valkey Command Manual