SCARD(3valkey)

πŸ“¦
version 9.0.6 Β· 2 versions
, in fedora 44

✨ SCARD β€” the "how many besties are in this set" command πŸ’–

okay so welcome to SCARD, a page from the Valkey Command Manual (yes, that's the 3valkey manual name, she's famous). this one's a lil baby command and it's genuinely iconic for it. no notes. πŸŽ€


🌸 NAME 🌸

scard β€” Returns the number of members in a set.

like. that's it. that's the whole job. she counts your set and she counts it fast. πŸ¦‹


🫢 SYNOPSIS 🫢

SCARD key

πŸ’… DESCRIPTION πŸ’…

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

so basically: you hand her a key, she tells you how many things are chillin' inside that set. that's the cardinality. it's giving census bureau but make it cute. ✨


🌈 REPLY 🌈

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

no cap, if the key isn't even there, you get 0. she's not gonna throw hands about it, she's just gonna be like "bestie, zero." 🫢

⭐ COMPLEXITY ⭐

O(1)

constant time, bestie. instant. she does not scroll. she does not search. she just knows. main character energy fr fr πŸ”₯


πŸ‘‘ ACL CATEGORIES πŸ‘‘

  • @fast
  • @read
  • @set

🧚 HISTORY 🧚

  • Available since: 1.0.0

she's been here since day one, literally a founding member of the group chat. periodt. πŸ’œ


πŸ“ 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

look at her go. two adds, one count, 2 on the board. ate and left no crumbs. πŸ˜­πŸ’–


πŸ”₯ 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)

the whole set-command friend group. go say hi. they're all lovely. πŸ’€πŸŒΈ


okay that's the page!! this was Valkey version 9.0.0, dated 2025-10-21, and that's a wrap bestie β€” go count something. mwah. πŸ’…βœ¨

πŸ“¦ where this page comes from