{
  "schema_version": 2,
  "id": "commands/msetex",
  "title": "MSETEX",
  "url": "https://redis.io/docs/latest/commands/msetex/",
  "summary": "Atomically sets multiple string keys with a shared expiration in a single operation. Supports flexible argument parsing where condition and expiration flags can appear in any order.",
  "since": "8.4.0",
  "tags": [
    "docs",
    "develop",
    "stack",
    "oss",
    "rs",
    "rc",
    "oss",
    "kubernetes",
    "clients"
  ],
  "last_updated": "2026-09-18T16:45:12+01:00",
  "page_type": "content",
  "content_hash": "b190a47085a32430a788dc456c51d218fa54b0d20325f01a6fc438cf6ab7441c",
  "sections": [
    {
      "id": "overview",
      "title": "Overview",
      "role": "overview",
      "text": "Atomically sets multiple string keys with an optional shared expiration in a single operation."
    },
    {
      "id": "required-arguments",
      "title": "Required arguments",
      "role": "content",
      "text": "<details open><summary><code>numkeys</code></summary>\n\nThe number of keys being set.\n\n</details>\n\n<details open><summary><code>key value [key value ...]</code></summary>\n\nA series of key/value pairs.\n\n</details>"
    },
    {
      "id": "optional-arguments",
      "title": "Optional arguments",
      "role": "parameters",
      "text": "The following options modify the command's behavior. The condition options (`NX`, `XX`) are mutually exclusive, as are the expiration options (`EX`, `PX`, `EXAT`, `PXAT`, `KEEPTTL`).\n\n<details open><summary><code>NX</code></summary>\n\nSet the keys and their expiration time only if none of the specified keys exist.\n\n</details>\n\n<details open><summary><code>XX</code></summary>\n\nSet the keys and their expiration time only if all of the specified keys already exist.\n\n</details>\n\n<details open><summary><code>EX seconds</code></summary>\n\nSet the specified expiration time in seconds (a positive integer).\n\n</details>\n\n<details open><summary><code>PX milliseconds</code></summary>\n\nSet the specified expiration time in milliseconds (a positive integer).\n\n</details>\n\n<details open><summary><code>EXAT unix-time-seconds</code></summary>\n\nSet the specified Unix time in seconds (a positive integer) at which the keys will expire.\n\n</details>\n\n<details open><summary><code>PXAT unix-time-milliseconds</code></summary>\n\nSet the specified Unix time in milliseconds (a positive integer) at which the keys will expire.\n\n</details>\n\n<details open><summary><code>KEEPTTL</code></summary>\n\nRetain the time to live associated with the keys.\n\n</details>"
    },
    {
      "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=\"Supported\">&#x2705; Standard</span><br /><span title=\"Supported\"><nobr>&#x2705; Active-Active</nobr></span> | <span title=\"Supported\">&#x2705; Standard</span><br /><span title=\"Supported\"><nobr>&#x2705; Active-Active</nobr></span> |  |"
    },
    {
      "id": "return-information",
      "title": "Return information",
      "role": "returns",
      "text": "**RESP2:**\n\n[Integer reply](https://redis.io/docs/latest/develop/reference/protocol-spec#integers): 0 if none of the keys were set; 1 if all of the keys were set.\n\n**RESP3:**\n\n[Integer reply](https://redis.io/docs/latest/develop/reference/protocol-spec#integers): 0 if none of the keys were set; 1 if all of the keys were set."
    }
  ],
  "examples": []
}
