Description
Set a timeout on a key. After the timeout has expired, the key will automatically be deleted.Method Signature
Parameters
string
required
The key to set expiration on
number
required
The number of seconds until the key expires
ExpireOption
Optional modifier for the expiration behavior:
"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 current one"LT"- Set expiry only when the new expiry is less than current one
"nx", "xx", "gt", "lt")Return Value
0 | 1
1if the timeout was set0if the timeout was not set (key doesn’t exist or condition not met)