Repository navigation
Conversation
|
Thanks @vikeychen . |
|
@oranagra got it, I will wait... |
|
Is this still in scope for 7.2? |
|
I'm also excited for this. |
|
@oranagra any chance to have this merged? |
|
sorry about the late response. 7.2 is mainly focused on optimizations, we'll consider this for 8.0 |
|
@vikeychen are you still around? pls fix the conflicts. thx |
I’ve already fixed the conflicts and pushed the update. Happy to make any further changes if needed. |
|
Hey @vikeychen more conflicts ;-) Would love to see this pr merged. |
|
I think the core devs are waiting for a 5-year anniversary of this PR to merge 🥳 |
…16135) Adds atomic sorted-set moves for end-of-set batches, score ranges and named members. Continues #10430 by @vikeychen. Related: #9989. Docs: redis/docs#4522. ```text ZMOVE source destination <MIN | MAX | BYSCORE score-min score-max> [COUNT count] BZMOVE source destination <MIN | MAX> timeout [COUNT count] ZMOVEMEMBER source destination [NX | XX] MEMBERS num-members member [member ...] ``` ### Reply - When members are moved, the reply is an array of `[member, score]` pairs, nested even for one member. Scores are bulk strings in RESP2 and doubles in RESP3. - When nothing is moved, the reply is nil (RESP2 `*-1`, RESP3 `_`). That covers a missing source, no matching or eligible member, source == destination, and a BZMOVE timeout. It also covers BZMOVE inside MULTI or a script when the source is empty. - Reply order: - MIN and BYSCORE: ascending (score, then member); - MAX: descending; - ZMOVEMEMBER: argument order, with duplicates once and missing members skipped. ### Semantics - `COUNT` must be positive. Zero, negative or malformed values return `ERR count should be greater than 0` before anything moves or blocks, as ZMPOP does. The default count is 1 for MIN/MAX. BYSCORE moves the whole matching range by default. - `BYSCORE` takes ZRANGEBYSCORE-style bounds (`(`, `-inf`, `+inf`). It has no LIMIT offset. - `BZMOVE` blocks on the source only. It wakes as soon as the source has a member and moves up to COUNT; it doesn't wait for a full batch. When members are moved, it is propagated as `ZMOVE source destination MIN|MAX [COUNT count]`. - `ZMOVEMEMBER`: - The counted `MEMBERS` block keeps member data apart from options, like HSETEX `FIELDS`. NX/XX may appear before or after the block, so a member named `NX` or `MEMBERS` is unambiguous. - With NX, only members absent from the destination move; with XX, only members already present there move. Members that aren't moved stay in the source. - With no condition, the source score overwrites the destination score. - Source == destination returns nil right after the type check, without reading any member. BZMOVE does not block in that case. - An emptied source is deleted. An existing destination keeps its TTL; a new destination has none. In cluster mode both keys must hash to the same slot. ### Keyspace notifications These fire only when at least one member moved: - Source: - `zpopmin` / `zpopmax` for MIN/MAX; - `zrem` for BYSCORE and ZMOVEMEMBER; - `del` when the source is emptied. - Destination: `zadd`, but only if the destination actually changed. Moving a member that already has the same score doesn't count as a change. A newly created destination also gets `new`. --------- Co-authored-by: vikeychen <[email protected]> Co-authored-by: debing.sun <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
|
Closed via #16135 |
zmoveis likelmove,the format isZMOVE <source> <destination> MIN|MAX, when specify min the moved element will be the minimum score element in the source.bzmoveis the blocking version ofzmove.zmovmemberis likesmove, the format isZMOVEMEMBER <source> <destination> member.see #9989
Note
Medium Risk
Adds new write and blocking sorted-set commands that modify keyspace events, replication rewriting, and memory/keysize accounting paths; mistakes could cause inconsistent state or replication divergence.
Overview
Adds three new sorted-set commands:
ZMOVE(move min/max element),ZMOVEMEMBER(move a specific member), and blockingBZMOVE(wait for an element, then move it).Implements shared move logic in
t_zset.c, including helpers to fetch min/max elements across encodings, proper deletion/creation of source/destination keys, keyspace notifications, dirty/memory/keysize accounting, and replication rewriting (BZMOVEpropagates asZMOVE).Updates command metadata (
commands.defand newsrc/commands/*.json), registers new shared object/prototypes, and adds extensive integration/unit tests for clustering (CROSSSLOT), COMMAND introspection, replication behavior, blocking semantics, RESP parsing, and wrong-type/syntax handling.Reviewed by Cursor Bugbot for commit 1733a7c. Bugbot is set up for automated code reviews on this repo. Configure here.