I need to create a set in Redis:
redis> SADD myset "Hello"
(integer) 1
redis> SADD myset "World"
(integer) 1
redis> SADD myset "World"
(integer) 0
redis> SMEMBERS myset
1) "World"
2) "Hello"
But I need to set expire time for the key myset
.
In other words I need a command kind of expire sadd myset...
(like SETEX for string values).
Is there any way to execute these commands per one request to Redis server?
2
Answers
There is no built-in command to do this. What you may do is; using transactions. As it is stated in the documentation;
There is also the possibility of using a Lua script to tie the two commands together: