GETEX

Since 1.1.0Strings

Syntax

GETEX key [EX s | PX ms | EXAT ts | PXAT ts | PERSIST]
  • Flags: fast, write
  • ACL categories: @fast, @string, @write
  • Arity: -2

Returns the string at key and, optionally, changes its expiry.

Options

OptionEffect
EX seconds, PX millisecondsExpire the key after this long.
EXAT unix-seconds, PXAT unix-millisecondsExpire the key at this time.
PERSISTRemove the key's expiry.

Without an option, GETEX is GET.

Reply

  • The value, or nil if 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