{
  "id": "lmovem",
  "title": "LMOVEM",
  "url": "https://redis.io/docs/latest/commands/lmovem/",
  "summary": "Moves up to (or exactly) a number of elements from one list to another and returns them. Deletes the source list if it becomes empty.",
  "tags": [
    "docs",
    "develop",
    "stack",
    "oss",
    "rs",
    "rc",
    "oss",
    "kubernetes",
    "clients"
  ],
  "last_updated": "2026-07-30T08:54:30-07:00",
  "page_type": "content",
  "content_hash": "e423dea0f79c2671b08f024cb50b69db29aec9a2e21e50caf778ad48a094813d",
  "sections": [
    {
      "id": "overview",
      "title": "Overview",
      "role": "overview",
      "text": "This command's behavior varies in clustered Redis environments. See the [multi-key operations](https://redis.io/docs/latest/develop/using-commands/multi-key-operations) page for more information.\n\n\n\nAtomically moves one or more elements from the list stored at `source` to the\nlist stored at `destination` and returns the moved elements.\n`LMOVEM` is the multiple-element version of [`LMOVE`](https://redis.io/docs/latest/commands/lmove): without the\noptional `how-many` block, it behaves exactly like [`LMOVE`](https://redis.io/docs/latest/commands/lmove) but returns\nthe moved element as a one-element array."
    },
    {
      "id": "required-arguments",
      "title": "Required arguments",
      "role": "content",
      "text": "<details open><summary><code>source</code></summary>\n\nThe key of the source list.\n\n</details>\n\n<details open><summary><code>destination</code></summary>\n\nThe key of the destination list.\n\n</details>\n\n<details open><summary><code>LEFT | RIGHT</code></summary>\n\nThe end of `source` to pop elements from: `LEFT` (head) or `RIGHT` (tail).\n\n</details>\n\n<details open><summary><code>LEFT | RIGHT</code></summary>\n\nThe end of `destination` to push elements to: `LEFT` (head) or `RIGHT` (tail).\n\n</details>"
    },
    {
      "id": "optional-arguments",
      "title": "Optional arguments",
      "role": "parameters",
      "text": "The `how-many` block controls how many elements are moved and in what order.\nWhen you include it, you must provide both a selector (`COUNT` or `EXACTLY`)\nand an ordering (`OBO` or `BULK`).\n\n<details open><summary><code>COUNT count | EXACTLY exactly</code></summary>\n\nThe number of elements to move:\n\n- `COUNT count` moves up to `count` elements. If `source` holds fewer than\n  `count` elements, all of them are moved. This matches the `count` semantics of\n  [`LPOP`](https://redis.io/docs/latest/commands/lpop) and [`LMPOP`](https://redis.io/docs/latest/commands/lmpop).\n- `EXACTLY exactly` moves exactly `exactly` elements. If `source` holds fewer\n  than `exactly` elements, nothing is moved and the command returns nil.\n\n</details>\n\n<details open><summary><code>OBO | BULK</code></summary>\n\nThe order in which elements are pushed onto `destination`:\n\n- `OBO` (one by one) moves elements individually: each element is popped from\n  `source` and pushed to `destination` before the next one is moved.\n- `BULK` moves all of the elements at once, preserving their relative order.\n\nThe two orderings differ only in the resulting arrangement of elements. See\n[Element ordering](#element-ordering) for details.\n\n</details>"
    },
    {
      "id": "examples",
      "title": "Examples",
      "role": "example",
      "text": "[code example]"
    },
    {
      "id": "details",
      "title": "Details",
      "role": "content",
      "text": ""
    },
    {
      "id": "moving-multiple-elements",
      "title": "Moving multiple elements",
      "role": "content",
      "text": "`LMOVEM` moves elements from one end of `source` (selected by the first\n`LEFT | RIGHT` argument) to one end of `destination` (selected by the second\n`LEFT | RIGHT` argument), and returns the moved elements as an array. If\n`source` does not exist, no operation is performed and the command returns an\nempty array (or nil when `EXACTLY` is used).\n\nThe `COUNT` and `EXACTLY` selectors decide how many elements are moved:\n\n- With `COUNT count`, the command moves up to `count` elements. If `source`\n  holds fewer than `count` elements, all available elements are moved.\n- With `EXACTLY exactly`, the command moves the requested number of elements\n  only if `source` holds at least that many. Otherwise it moves nothing and\n  returns nil. This is useful when elements form fixed-size groups (for example,\n  pairs or triplets) that must be moved together or not at all."
    },
    {
      "id": "element-ordering",
      "title": "Element ordering",
      "role": "content",
      "text": "The `OBO` and `BULK` orderings determine how the moved elements are arranged on\n`destination`:\n\n- `OBO` (one by one) pops and pushes each element in turn, so an element popped\n  earlier ends up \"beneath\" one popped later at the destination end.\n- `BULK` moves the whole batch at once, preserving the elements' relative order.\n\nWhen `source` and `destination` are the same key, this difference becomes a\nuseful side effect. `BULK` leaves the list unchanged (the elements are removed\nand re-added in the same order), so it is effectively a no-op. `OBO`, however,\nreverses the moved elements in place. For example, with `mylist` holding\n`a, b, c`, running `LMOVEM mylist mylist LEFT LEFT EXACTLY 2 OBO` pops `a` then\n`b` and pushes each back to the head, leaving `mylist` as `b, a, c`."
    },
    {
      "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* [Array reply](../../develop/reference/protocol-spec#arrays): the moved elements, in destination order.\n* [Nil reply](../../develop/reference/protocol-spec#bulk-strings): if `EXACTLY` was used and `source` did not hold enough elements.\n\n**RESP3:**\n\nOne of the following:\n* [Array reply](../../develop/reference/protocol-spec#arrays): the moved elements, in destination order.\n* [Null reply](../../develop/reference/protocol-spec#nulls): if `EXACTLY` was used and `source` did not hold enough elements."
    },
    {
      "id": "see-also",
      "title": "See also",
      "role": "related",
      "text": "[`LMOVE`](https://redis.io/docs/latest/commands/lmove/) | [`BLMOVEM`](https://redis.io/docs/latest/commands/blmovem/) | [`LMPOP`](https://redis.io/docs/latest/commands/lmpop/) | [`RPOPLPUSH`](https://redis.io/docs/latest/commands/rpoplpush/)"
    },
    {
      "id": "related-topics",
      "title": "Related topics",
      "role": "related",
      "text": "- [Redis lists](https://redis.io/docs/latest/develop/data-types/lists)"
    }
  ],
  "examples": [
    {
      "id": "examples-ex0",
      "language": "plaintext",
      "code": "> rpush mylist 1 2 3 4\n(integer) 4\n> LMOVEM mylist myotherlist LEFT LEFT COUNT 2 OBO\n1) \"2\"\n2) \"1\"\n> LRANGE mylist 0 -1\n1) \"3\"\n2) \"4\"\n> LRANGE myotherlist 0 -1\n1) \"2\"\n2) \"1\"\n> LMOVEM mylist myotherlist LEFT LEFT EXACTLY 5 BULK\n(nil)\n> RPUSH somelist a b c\n(integer) 3\n> LMOVEM somelist somelist LEFT LEFT EXACTLY 2 OBO\n1) \"b\"\n2) \"a\"\n> LRANGE somelist 0 -1\n1) \"b\"\n2) \"a\"\n3) \"c\"",
      "section_id": "examples"
    }
  ]
}
