{
  "schema_version": 2,
  "id": "commands/bzmove",
  "title": "BZMOVE",
  "url": "https://redis.io/docs/latest/commands/bzmove/",
  "summary": "Moves highest- or lowest-scoring members from one sorted set to another, preserving scores. Blocks until a member is available otherwise. Deletes the source sorted set if the last member was moved.",
  "since": "8.12.0",
  "tags": [
    "docs",
    "develop",
    "stack",
    "oss",
    "rs",
    "rc",
    "oss",
    "kubernetes",
    "clients"
  ],
  "last_updated": "2026-11-23T06:19:08-08:00",
  "page_type": "content",
  "content_hash": "f53ee36e2640c37e7ac72459651b748e763e57792039b1d86835e455cbc75b3f",
  "sections": [
    {
      "id": "overview",
      "title": "Overview",
      "role": "overview",
      "text": "`BZMOVE` is the blocking variant of [`ZMOVE`](https://redis.io/docs/latest/commands/zmove) for\nmoving lowest-scoring or highest-scoring members between sorted sets.\nWhen `source` contains members, it behaves like `ZMOVE` with the same `MIN` or\n`MAX` selector and optional `COUNT`.\n\nWhen `source` does not exist, the connection waits until at least one member\nbecomes available or the timeout expires. When members become available, it\nmoves up to `count` members without waiting for a full batch. If the timeout\nexpires first, it returns null. Changes to `destination` do not unblock the\nconnection. `BYSCORE` is not supported.\n\nMoved members retain their source scores. If a member already exists in\n`destination`, that score is overwritten. Other destination members are\nretained. Redis creates `destination` if needed and deletes `source` when its\nlast member is moved. Existing expiration times are preserved; a newly created\ndestination has no expiration.\n\nIf both arguments name the same sorted set or the same nonexistent key, the\ncommand returns null without moving members or blocking. Inside a\n[`MULTI`](https://redis.io/docs/latest/commands/multi)/[`EXEC`](https://redis.io/docs/latest/commands/exec)\ntransaction or a script, the command does not block. If no member is available,\nit returns null.\n\nA source key of the wrong type causes a `WRONGTYPE` error immediately.\nThe destination type is checked when members are available to move. If a\nblocked client wakes and `destination` holds another type, the command returns\n`WRONGTYPE` and leaves the source members unchanged.\n\nIn Redis Open Source Cluster, both keys must be in the same hash slot.\nSee [multi-key operations](https://redis.io/docs/latest/develop/using-commands/multi-key-operations)."
    },
    {
      "id": "required-arguments",
      "title": "Required arguments",
      "role": "content",
      "text": "<details open><summary><code>source</code></summary>\n\nThe key of the sorted set to move members from. This is the only key the\ncommand blocks on.\n\n</details>\n\n<details open><summary><code>destination</code></summary>\n\nThe key of the sorted set to move members to.\n\n</details>\n\n<details open><summary><code>MIN | MAX</code></summary>\n\nMove the members with the lowest scores (`MIN`) or highest scores (`MAX`).\n`MIN` returns members in ascending score order, and `MAX` in descending score\norder. Equal scores follow the corresponding lexicographical member order.\n\n</details>\n\n<details open><summary><code>timeout</code></summary>\n\nThe maximum time to block, in seconds. This is a non-negative double, so\nfractional seconds are allowed. A timeout of `0` blocks indefinitely.\n\n</details>"
    },
    {
      "id": "optional-arguments",
      "title": "Optional arguments",
      "role": "parameters",
      "text": "<details open><summary><code>COUNT count</code></summary>\n\nMove at most `count` available members. The default is `1`. `count` must be a\npositive integer. Zero and negative counts return\n`ERR count should be greater than 0` before moving members or blocking.\n\n</details>"
    },
    {
      "id": "examples",
      "title": "Examples",
      "role": "example",
      "text": "Move the available members without waiting for a full batch:\n\n\nredis> ZADD ready:{example} 1 first 2 second\n(integer) 2\nredis> BZMOVE ready:{example} processing:{example} MIN 1 COUNT 3\n1) 1) \"first\"\n   2) \"1\"\n2) 1) \"second\"\n   2) \"2\"\nredis> BZMOVE ready:{example} processing:{example} MIN 0 COUNT 0\n(error) ERR count should be greater than 0\n\n\nTo wait for a producer, run the following command when `ready:{queue}` does\nnot exist:\n\n[code example]\n\nIn a second connection, run `ZADD ready:{queue} 1 job:1`. The blocked command\nreturns one nested member/score pair for `job:1`; it does not wait for nine\nmore members."
    },
    {
      "id": "redis-software-and-redis-cloud-compatibility",
      "title": "Redis Software and Redis Cloud compatibility",
      "role": "content",
      "text": "| Redis<br />Software | Redis<br />Cloud | <span style=\"min-width: 9em; display: table-cell\">Notes</span> |\n|:----------------------|:-----------------|:------|\n| <span title=\"Not supported\">&#x274c; Standard</span><br /><span title=\"Not supported\"><nobr>&#x274c; Active-Active</nobr></span> | <span title=\"Not supported\">&#x274c; Standard</span><br /><span title=\"Not supported\"><nobr>&#x274c; Active-Active</nobr></span> |  |"
    },
    {
      "id": "return-information",
      "title": "Return information",
      "role": "returns",
      "text": "**RESP2:**\n\nOne of the following:\n\n- [Array reply](https://redis.io/docs/latest/develop/reference/protocol-spec#arrays): an array of\n  two-element member/score arrays, nested even when only one member is moved.\n  Each score is a bulk string. Pairs follow the selected order.\n- [Nil reply](https://redis.io/docs/latest/develop/reference/protocol-spec#null-arrays): the timeout\n  expired, both keys name the same sorted set, or blocking is disallowed and\n  no member is available.\n\n**RESP3:**\n\nOne of the following:\n\n- [Array reply](https://redis.io/docs/latest/develop/reference/protocol-spec#arrays): an array of\n  two-element member/score arrays, nested even when only one member is moved.\n  Each score is a double. Pairs follow the selected order.\n- [Null reply](https://redis.io/docs/latest/develop/reference/protocol-spec#nulls): the timeout\n  expired, both keys name the same sorted set, or blocking is disallowed and\n  no member is available."
    }
  ],
  "examples": [
    {
      "id": "examples-ex0",
      "language": "text",
      "code": "BZMOVE ready:{queue} processing:{queue} MIN 0 COUNT 10",
      "section_id": "examples"
    }
  ]
}
