SETEX

SETEX

SETEX key seconds value
Available since
2.0.0
Time complexity
O(1)
ACL categories
@write, @string, @slow

Set key to hold the string value and set key to timeout after a given number of seconds. This command is equivalent to:

SET key value EX seconds

An error is returned when seconds is invalid.

Examples #

SETEX mykey 10 "Hello"
TTL mykey
GET mykey

See also #

TTL

Redict logo courtesy of @janWilejan, CC-BY-SA-4.0. Download SVG ⤑

Portions of this website courtesy of Salvatore Sanfilippo, CC-BY-SA-4.0.