HEXPIREAT

HEXPIREAT key unix-time-seconds [NX | XX | GT | LT] FIELDS numfields
  field [field ...]
Available since:
Redis Open Source 7.4.0
Time complexity:
O(N) where N is the number of specified fields
ACL categories:
@write, @hash, @fast,
Compatibility:
Redis Software and Redis Cloud compatibility

HEXPIREAT has the same effect and semantics as HEXPIRE, but instead of specifying the number of seconds for the TTL (time to live), it takes an absolute Unix timestamp in seconds since Unix epoch. A timestamp in the past will delete the field immediately.

For the specific semantics of the command, see HEXPIRE.

Required arguments

key

The name of the key that holds the hash.

unix-time-seconds

The absolute Unix expiration timestamp, in seconds since Unix epoch. A timestamp in the past deletes the field immediately.

FIELDS numfields field [field ...]

The hash fields to set expiration for. numfields is the number of fields, followed by that many field names.

Optional arguments

The following options modify the command's behavior. They are mutually exclusive.

NX

For each specified field, set expiration only when the field has no expiration.

XX

For each specified field, set expiration only when the field has an existing expiration.

GT

For each specified field, set expiration only when the new expiration is greater than the current one. A non-volatile key is treated as an infinite TTL for the purposes of GT.

LT

For each specified field, set expiration only when the new expiration is less than the current one. A non-volatile key is treated as an infinite TTL for the purposes of LT.

Examples

redis> HSET mykey field1 "hello" field2 "world"
(integer) 2
redis> HEXPIREAT mykey 1715704971 FIELDS 2 field1 field2
1) (integer) 1
2) (integer) 1
redis> HTTL mykey FIELDS 2 field1 field2
1) (integer) 567
2) (integer) 567

Redis Software and Redis Cloud compatibility

Redis
Software
Redis
Cloud
Notes
✅ Standard
✅ Active-Active
✅ Standard
✅ Active-Active

Return information

One of the following:

  • Array reply. For each field:
    • Integer reply: -2 if no such field exists in the provided hash key, or the provided key does not exist.
    • Integer reply: 0 if the specified NX, XX, GT, or LT condition has not been met.
    • Integer reply: 1 if the expiration time was set/updated.
    • Integer reply: 2 when HEXPIRE or HPEXPIRE is called with 0 seconds or milliseconds, or when HEXPIREAT or HPEXPIREAT is called with a past Unix time in seconds or milliseconds.
  • Simple error reply:
    • if parsing failed, mandatory arguments are missing, unknown arguments are specified, or argument values are of the wrong type or out of range.
    • if the provided key exists but is not a hash.
RATE THIS PAGE
Back to top ↑