HPEXPIREAT
HPEXPIREAT key unix-time-milliseconds [NX | XX | GT | LT] FIELDS numfields field [field ...]
- Group
- Hash
- Complexity
- O(N) where N is the number of fields given
- Arity
- -6 (at least 6 words, counting the command name)
- Flags
- write, fast
- Keys
- first 1, last 1, step 1
- HotKV Cloud
- All plans
- On-Premise
- no license needed
HPEXPIREAT works like HEXPIREAT, but the timestamp
is in milliseconds since the Unix epoch. A timestamp already in the past
deletes the fields at once (result code 2).
Options
Section titled “Options”| Option | Effect |
|---|---|
NX |
Set the expiry only on fields that have none. |
XX |
Set the expiry only on fields that already have one. |
GT |
Set the expiry only if it is later than the field’s current one. A field without one never matches. |
LT |
Set the expiry only if it is earlier than the field’s current one. A field without one always matches. |
Return value
Section titled “Return value”An array with one integer per field, in the order given, under both RESP2 and RESP3:
| Code | Meaning |
|---|---|
-2 |
The field or the key does not exist. |
0 |
The condition was not met; nothing changed. |
1 |
The expiry was set. |
2 |
The time is already in the past, so the field was deleted. |
The errors are the same as for HEXPIRE; a timestamp too
far in the future gives ERR invalid expire time in 'hpexpireat' command.
Examples
Section titled “Examples”127.0.0.1:6379> HSET promo:3 code "SPRING"(integer) 1127.0.0.1:6379> HPEXPIREAT promo:3 1924992000500 FIELDS 1 code1) (integer) 1127.0.0.1:6379> HPEXPIRETIME promo:3 FIELDS 1 code1) (integer) 1924992000500Compatibility
Section titled “Compatibility”Same arguments and per-field result codes as Redis 7.4. Valkey 8 does not have hash field expiration.
See also
Section titled “See also”Was this page helpful?
Thanks for the feedback.