HGETEX key [EX seconds | PX milliseconds | EXAT unix-time-seconds | PXAT unix-time-milliseconds | PERSIST] FIELDS numfields field [field ...]
@write,
@hash,
@fast,
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 Enterprise |
Redis Cloud |
Notes |
|---|---|---|
| ✅ Standard ✅ Active-Active |
✅ Standard ✅ Active-Active |