{
  "schema_version": 2,
  "id": "commands/hgetex",
  "title": "HGETEX",
  "url": "https://redis.io/docs/latest/commands/hgetex/",
  "summary": "Get the value of one or more fields of a given hash key, and optionally set their expiration.",
  "since": "8.0.0",
  "tags": [
    "docs",
    "develop",
    "stack",
    "oss",
    "rs",
    "rc",
    "oss",
    "kubernetes",
    "clients"
  ],
  "last_updated": "2026-06-15T06:26:34-07:00",
  "page_type": "content",
  "content_hash": "bb21edbff009a32fc04e29651bb81d814d6ff572952fe9ddf7899a2a6a48cc40",
  "sections": [
    {
      "id": "overview",
      "title": "Overview",
      "role": "overview",
      "text": "Get the value of one or more fields of a given hash key and optionally set their expiration time or time-to-live (TTL)."
    },
    {
      "id": "required-arguments",
      "title": "Required arguments",
      "role": "content",
      "text": "<details open><summary><code>key</code></summary>\n\nThe name of the key that holds the hash.\n\n</details>\n\n<details open><summary><code>FIELDS numfields field [field ...]</code></summary>\n\nThe hash fields to retrieve. `numfields` is the number of fields, followed by that many field names.\n\n</details>"
    },
    {
      "id": "optional-arguments",
      "title": "Optional arguments",
      "role": "parameters",
      "text": "The following options modify the command's behavior. They are mutually exclusive.\n\n<details open><summary><code>EX seconds</code></summary>\n\nSet the specified expiration time, in seconds.\n\n</details>\n\n<details open><summary><code>PX milliseconds</code></summary>\n\nSet the specified expiration time, in milliseconds.\n\n</details>\n\n<details open><summary><code>EXAT unix-time-seconds</code></summary>\n\nSet the specified Unix time at which the fields will expire, in seconds.\n\n</details>\n\n<details open><summary><code>PXAT unix-time-milliseconds</code></summary>\n\nSet the specified Unix time at which the fields will expire, in milliseconds.\n\n</details>\n\n<details open><summary><code>PERSIST</code></summary>\n\nRemove the TTL associated with the fields.\n\n</details>"
    },
    {
      "id": "examples",
      "title": "Examples",
      "role": "example",
      "text": "[code example]"
    },
    {
      "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* [Array reply](../../develop/reference/protocol-spec#arrays): a list of values associated with the given fields, in the same order as they are requested.\n\n**RESP3:**\n\n* [Array reply](../../develop/reference/protocol-spec#arrays): a list of values associated with the given fields, in the same order as they are requested."
    }
  ],
  "examples": [
    {
      "id": "examples-ex0",
      "language": "plaintext",
      "code": "redis> HSET mykey field1 \"Hello\" field2 \"World\"\n(integer) 2\nredis> HGETEX mykey EX 120 FIELDS 1 field1\n1) \"Hello\"\nredis> HGETEX mykey EX 100 FIELDS 1 field2\n1) \"World\"\nredis> HTTL mykey FIELDS 2 field1 field2\n1) (integer) 91\n2) (integer) 85\nredis> HTTL mykey FIELDS 3 field1 field2 field3 \n1) (integer) 75\n2) (integer) 68\n3) (integer) -2\n...\nredis> HTTL mykey FIELDS 3 field1 field2 \n1) (integer) -2\n2) (integer) -2\nredis> HGETALL mykey\n(empty array)",
      "section_id": "examples"
    }
  ]
}
