GETEX
Since 1.1.0Strings
Syntax
GETEX key [EX s | PX ms | EXAT ts | PXAT ts | PERSIST]Returns the string at key and, optionally, changes its expiry.
Options
| Option | Effect |
|---|---|
EX seconds, PX milliseconds | Expire the key after this long. |
EXAT unix-seconds, PXAT unix-milliseconds | Expire the key at this time. |
PERSIST | Remove the key's expiry. |
Without an option, GETEX is GET.
Reply
- The value, or
nilif the key does not exist; a missing key is not created.
Examples
> SET g v EX 100
OK
> GETEX g PERSIST
"v"
> TTL g
(integer) -1
> GETEX g PX 5000
"v"
> PTTL g
(integer) 5000