Back to Redis

HPEXPIREAT

content/commands/hpexpireat.md

latest3.7 KB
Original Source

HPEXPIREAT has the same effect and semantics as [HEXPIREAT]({{< relref "/commands/hexpireat" >}}), but the Unix time at which the field will expire is specified in milliseconds since Unix epoch instead of seconds.

Options

The HPEXPIREAT command supports a set of options:

  • 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 current one.
  • LT -- For each specified field, set expiration only when the new expiration is less than current one.

A non-volatile key is treated as an infinite TTL for the purposes of GT and LT. The NX, XX, GT, and LT options are mutually exclusive.

Example

redis> HSET mykey field1 "hello" field2 "world"
(integer) 2
redis> HPEXPIREAT mykey 1715704971000 FIELDS 2 field1 field2
1) (integer) 1
2) (integer) 1
redis> HPTTL mykey FIELDS 2 field1 field2
1) (integer) 303340
2) (integer) 303340

Redis Software and Redis Cloud compatibility

| 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> | |

Return information

{{< multitabs id="hpexpireat-return-info" tab1="RESP2" tab2="RESP3" >}}

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.

-tab-sep-

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.

{{< /multitabs >}}