content/commands/hgetex.md
Get the value of one or more fields of a given hash key and optionally set their expiration time or time-to-live (TTL).
The HGETEX command supports a set of options:
EX seconds -- Set the specified expiration time, in seconds.PX milliseconds -- Set the specified expiration time, in milliseconds.EXAT unix-time-seconds -- Set the specified Unix time at which the fields will expire, in seconds.PXAT unix-time-milliseconds -- Set the specified Unix time at which the fields will expire, in milliseconds.PERSIST -- Remove the TTL associated with the fields.The EX, PX, EXAT, PXAT, and PERSIST options are mutually exclusive.
redis> HSET mykey field1 "Hello" field2 "World"
(integer) 2
redis> HGETEX mykey EX 120 FIELDS 1 field1
1) "Hello"
redis> HGETEX mykey EX 100 FIELDS 1 field2
1) "World"
redis> HTTL mykey FIELDS 2 field1 field2
1) (integer) 91
2) (integer) 85
redis> HTTL mykey FIELDS 3 field1 field2 field3
1) (integer) 75
2) (integer) 68
3) (integer) -2
...
redis> HTTL mykey FIELDS 3 field1 field2
1) (integer) -2
2) (integer) -2
redis> HGETALL mykey
(empty array)
| Redis Software | Redis Cloud | <span style="min-width: 9em; display: table-cell">Notes</span> | |:----------------------|:-----------------|:------| | <span title="Supported">✅ Standard</span> <span title="Supported"><nobr>✅ Active-Active</nobr></span> | <span title="Supported">✅ Standard</span> <span title="Supported"><nobr>✅ Active-Active</nobr></span> | |
{{< multitabs id="hgetex-return-info" tab1="RESP2" tab2="RESP3" >}}
-tab-sep-
{{< /multitabs >}}