Back to Redis

HEXPIRETIME

content/commands/hexpiretime.md

latest2.0 KB
Original Source

Returns the absolute Unix timestamp in seconds since Unix epoch at which the given key's field(s) will expire.

See also the [HPEXPIRETIME]({{< relref "/commands/hpexpiretime" >}}) command, which returns the same information with millisecond resolution.

Examples

redis> HSET mykey field1 "hello" field2 "world"
(integer) 2
redis> HEXPIRE mykey 300  FIELDS 2 field1 field2
1) (integer) 1
2) (integer) 1
redis> HEXPIRETIME mykey FIELDS 2 field1 field2
1) (integer) 1715705914
2) (integer) 1715705914

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="hexpiretime-return-info" tab1="RESP2" tab2="RESP3" >}}

  • 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: -1 if the field exists but has no associated expiration set.
    • Integer reply: the expiration (Unix timestamp) in seconds.

-tab-sep-

  • 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: -1 if the field exists but has no associated expiration set.
    • Integer reply: the expiration (Unix timestamp) in seconds.

{{< /multitabs >}}