ZRANGESTORE(3valkey)
β¨ 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 π
bzmpop(3valkey)bzpopmax(3valkey)bzpopmin(3valkey)zadd(3valkey)zcard(3valkey)zcount(3valkey)zdiff(3valkey)zdiffstore(3valkey)zincrby(3valkey)zinter(3valkey)zintercard(3valkey)zinterstore(3valkey)zlexcount(3valkey)zmpop(3valkey)zmscore(3valkey)zpopmax(3valkey)zpopmin(3valkey)zrandmember(3valkey)zrange(3valkey)zrangebylex(3valkey)zrangebyscore(3valkey)zrank(3valkey)zrem(3valkey)zremrangebylex(3valkey)zremrangebyrank(3valkey)zremrangebyscore(3valkey)zrevrange(3valkey)zrevrangebylex(3valkey)zrevrangebyscore(3valkey)zrevrank(3valkey)zscan(3valkey)zscore(3valkey)zunion(3valkey)zunionstore(3valkey)
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
- fedora 44: valkey-doc 9.0.3-2.fc44 Β· CC-BY-SA-4.0
- fedora 44: valkey-doc 9.0.6-1.fc44 Β· CC-BY-SA-4.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms