ZCARD(3valkey)

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

✨ ZCARD β€” the vibe check for your sorted set πŸ’…

okay bestie, welcome to the ZCARD page of the Valkey Command Manual, section 3valkey. this one is short, sweet, and honestly iconic. no notes. πŸŽ€


🌸 NAME 🌸

zcard β€” returns the number of members in a sorted set. that's it. that's the whole job. she does one thing and she slays it. ✨


πŸ¦‹ SYNOPSIS πŸ¦‹

ZCARD key

πŸ’– DESCRIPTION πŸ’–

so basically, ZCARD hands you back the sorted set cardinality β€” which is just a fancy way of saying the number of elements β€” of the sorted set that's chillin' at key. count 'em up, bestie, that's the whole command. πŸ’…


🫢 REPLY 🫢

per valkey-protocol(7), you get an Integer reply: the cardinality (aka the number of members) of that sorted set. and if the key doesn't exist? you get 0. no drama, no error, just a polite little zero. πŸ“


⭐ COMPLEXITY ⭐

O(1) β€” constant time, babes. instant. she doesn't even break a sweat. πŸ”₯


πŸ‘‘ ACL CATEGORIES πŸ‘‘

  • @fast
  • @read
  • @sortedset

🌈 HISTORY 🌈

  • Available since: 1.2.0 β€” a true veteran, been serving looks since forever. πŸ’œ

🧚 EXAMPLES 🧚

127.0.0.1:6379> ZADD myzset 1 "one"
(integer) 1
127.0.0.1:6379> ZADD myzset 2 "two"
(integer) 1
127.0.0.1:6379> ZCARD myzset
(integer) 2

look at her go. added two members, asked for the count, got 2. main character energy fr fr. ✨


πŸ’€ SEE ALSO πŸ’€


and that's the tea, bestie πŸ«– this page is from Valkey version 9.0.0, dated 2025-10-21. go forth and count your members. periodt. πŸ’…βœ¨πŸŽ€

πŸ“¦ where this page comes from