SETEX

Stores a string with an expiry measured in seconds.

Strings · Example verified

Syntax covered here

SETEX key seconds value

The case overwrites an existing string and checks the resulting positive lifetime with PTTL.

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
> SETEX greeting 60 world
"OK"
# connection: default
> PTTL greeting
60000