SETEX
Syntax
1. SETEX key seconds value
Time complexity: O(1)
Set key to hold the string value and set key to timeout after a given number of seconds. This command is equivalent to executing the following commands:
1. SET mykey value
2. EXPIRE mykey seconds
SETEX is atomic, and can be reproduced by using the previous two commands inside an MULTI / EXEC block. It is provided as a faster alternative to the given sequence of operations, because this operation is very common when Redis is used as a cache.
An error is returned when seconds is invalid.
Return
Examples
1. dragonfly> SETEX mykey 10 "Hello"
2. "OK"
3. dragonfly> TTL mykey
4. (integer) 10
5. dragonfly> GET mykey
6. "Hello"
