ZSCAN(3valkey)

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

✨ ZSCAN ✨

okay bestie, welcome to ZSCAN πŸ’– this is a page from the valkey command manual (section 3valkey, iykyk) and it's literally about iterating over members and scores of a sorted set πŸ¦‹


🌸 NAME 🌸

zscan β€” iterates over members and scores of a sorted set. that's the whole vibe. πŸ‘‘


πŸŽ€ SYNOPSIS πŸŽ€

ZSCAN key cursor [MATCH pattern] [COUNT count] [NOSCORES]

See SCAN for ZSCAN documentation. (yes bestie, the real lore lives over there, this page is the cute little redirect-with-extras situation πŸ’…)


πŸ’œ REPLY πŸ’œ

it gives you back a valkey-protocol(7) Array reply: a two-element array. two elements. that's it. 🫢

  • the first element is a valkey-protocol(7) Bulk string reply that represents an unsigned 64-bit number β€” that's your cursor, bestie, hold onto it fr fr.
  • the second element is a valkey-protocol(7) Array reply of member/score pairs that were scanned. but ✨ when the NOSCORES option is on ✨ it's just a list of members from the sorted set. no scores, no problem. πŸ“

⭐ COMPLEXITY ⭐

  • O(1) for every call. every single one. iconic.
  • O(N) for a complete iteration, including enough command calls for the cursor to return back to 0. and N is the number of elements inside the collection. so like, the more stuff you got, the longer the full loop takes. math is math. πŸ’€

πŸ‘‘ ACL CATEGORIES πŸ‘‘

@read @slow @sortedset


πŸ¦‹ HISTORY πŸ¦‹

  1. available since: 2.8.0 🌱
  2. changed in 8.0.0: added noscores option. glow up era. ✨

πŸ’– SEE ALSO πŸ’–

go read these too, bestie, they're all in the sorted set cinematic universe 🌈


okay that's the whole page, bestie, you ate that reading session fr fr πŸ’…βœ¨

this little love letter came from Valkey Command Manual, version 9.0.0, dated 2025-10-21 β€” mwah, go forth and scan responsibly πŸ«ΆπŸŽ€

πŸ“¦ where this page comes from