ZRANGESTORE(3valkey)

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

✨ ZRANGESTORE ✨

okay so bestie, welcome to the Valkey Command Manual πŸ’– this one lives in section 3valkey and it's genuinely one of my faves, no cap.


πŸŽ€ NAME πŸŽ€

zrangestore β€” stores a range of members from sorted set in a key. iconic behaviour honestly πŸ¦‹


🫢 SYNOPSIS 🫢

ZRANGESTORE dst src min max [BYSCORE | BYLEX] [REV] [LIMIT offset count]

like. look at her. she's got it all πŸ’…


🌸 DESCRIPTION 🌸

so this command is literally ZRANGE, but it stores the result in the <dst> destination key instead of just yelling it back at you. the way that it takes the range and just... puts it somewhere. main character energy fr fr ✨


πŸ’Œ REPLY πŸ’Œ

valkey-protocol(7) Integer reply: the number of elements in the resulting sorted set. that's the count of what actually landed in <dst>, bestie πŸ“


⚑ COMPLEXITY ⚑

O(log(N)+M) with N being the number of elements in the sorted set and M the number of elements stored into the destination key. so like, loggy for the lookup, M for the copying. math ate πŸ’€


πŸ‘‘ ACL CATEGORIES πŸ‘‘

  • @slow
  • @sortedset
  • @write

πŸ•°οΈ HISTORY πŸ•°οΈ

  • Available since: 6.2.0 ⭐

🌈 EXAMPLES 🌈

127.0.0.1:6379> ZADD srczset 1 "one" 2 "two" 3 "three" 4 "four"
(integer) 4
127.0.0.1:6379> ZRANGESTORE dstzset srczset 2 -1
(integer) 2
127.0.0.1:6379> ZRANGE dstzset 0 -1
1) "three"
2) "four"

see how she grabbed "three" and "four" and yeeted them into dstzset? that's the whole vibe 🧚


πŸ’œ SEE ALSO πŸ’œ

the whole sorted-set friend group showed up, obsessed 😭🫢


k bye bestie, go store some ranges, you got this πŸ’…βœ¨

version 9.0.0, dated 2025-10-21, straight from the ZRANGESTORE(3valkey) page. mwah πŸ’–

πŸ“¦ where this page comes from