PEXPIREAT
PEXPIREAT key unix-time-milliseconds [NX | XX | GT | LT]
- Available since:
- Redis Open Source 2.6.0
- Time complexity:
- O(1)
- ACL categories:
-
@keyspace,@write,@fast, - Compatibility:
- Redis Software and Redis Cloud compatibility
PEXPIREAT has the same effect and semantic as EXPIREAT, but the Unix time at
which the key will expire is specified in milliseconds instead of seconds.
Required arguments
key
The name of the key to set a timeout on.
unix-time-milliseconds
The absolute Unix expiration timestamp, in milliseconds since Unix epoch. A timestamp in the past deletes the key immediately.
Optional arguments
The following options modify the command's behavior. They are mutually exclusive.
NX
Set expiry only when the key has no expiry.
XX
Set expiry only when the key has an existing expiry.
GT
Set expiry only when the new expiry is greater than the current one. A non-volatile key is treated as an infinite TTL for the purpose of GT.
LT
Set expiry only when the new expiry is less than the current one. A non-volatile key is treated as an infinite TTL for the purpose of LT.
Examples
Redis Software and Redis Cloud compatibility
| Redis Software |
Redis Cloud |
Notes |
|---|---|---|
| ✅ Standard |
✅ Standard |
Return information
One of the following:
- Integer reply:
1if the timeout was set. - Integer reply:
0if the timeout was not set. For example, if the key doesn't exist, or the operation was skipped due to the provided arguments.
History
- Starting with Redis version 7.0.0: Added options:
NX,XX,GTandLT.