GETEX
GETEX key [EX seconds|PX milliseconds|EXAT timestamp|PXAT milliseconds-timestamp|PERSIST]
Get the value of key and optionally set its expiration. GETEX is similar to GET, but is a write command with additional options.
Options
The GETEX command supports a set of options that modify its behavior:
-
EXseconds -- Set the specified expire time, in seconds. -
PXmilliseconds -- Set the specified expire time, in milliseconds. -
EXATtimestamp-seconds -- Set the specified Unix time at which the key will expire, in seconds. -
PXATtimestamp-milliseconds -- Set the specified Unix time at which the key will expire, in milliseconds. - PERSIST -- Remove the time to live associated with the key.
Return value
Bulk string reply: the value of key, or nil when key does not exist.
Examples
redis> SET mykey "Hello"
"OK" redis> GETEX mykey "Hello" redis> TTL mykey (integer) -1 redis> GETEX mykey EX 60 "Hello" redis> TTL mykey (integer) 60
© 2009–2020 Salvatore Sanfilippo
Licensed under the Creative Commons Attribution-ShareAlike License 4.0.
https://redis.io/commands/getex