GETEX

Retrieves a string while setting its expiry in seconds.

Strings · Example verified

Syntax covered here

GETEX key EX seconds

The EX form returns the existing value, and PTTL verifies that a positive key lifetime was installed.

Tested example & replies

Requests below run in order against an empty database. Each connection authenticates with the fixture password first. Quoted values are strings; null is a nil reply; arrays preserve RESP order.

# connection: default
> SET greeting hello
"OK"
# connection: default
> GETEX greeting EX 60
"hello"
# connection: default
> PTTL greeting
60000