PEXPIREAT
PEXPIREAT key unix-time-milliseconds [NX | XX | GT | LT]
- Group
- Keys
- Complexity
- O(1)
- Arity
- -3 (at least 3 words, counting the command name)
- Flags
- write, fast
- Keys
- first 1, last 1, step 1
- HotKV Cloud
- All plans
- On-Premise
- no license needed
PEXPIREAT works like EXPIREAT, with the timestamp in
milliseconds since the Unix epoch. A timestamp in the past deletes the key at
once.
Options
Section titled “Options”| Option | Effect |
|---|---|
NX |
Set the time only if the key has none. |
XX |
Set the time only if the key already has one. |
GT |
Set the time only if it is later than the current one (never for a key without a time to live). |
LT |
Set the time only if it is earlier than the current one (always for a key without a time to live). |
Return value
Section titled “Return value”| Case | RESP2 | RESP3 |
|---|---|---|
| The time was set (or the key was deleted) | Integer 1 |
Integer 1 |
| The key does not exist, or an option prevented the change | Integer 0 |
Integer 0 |
The error replies are the same as for EXPIRE, with
'pexpireat' in the invalid-time message.
Examples
Section titled “Examples”127.0.0.1:6379> SET report "q3"OK127.0.0.1:6379> PEXPIREAT report 1893456000000(integer) 1127.0.0.1:6379> PEXPIRETIME report(integer) 1893456000000Compatibility
Section titled “Compatibility”Same as Redis 7 and Valkey 8.
See also
Section titled “See also”Was this page helpful?
Thanks for the feedback.