Redis Multi-Set With a TTL

Ian picture Ian · May 7, 2013 · Viewed 11.4k times · Source

In redis there is a SETEX command that allows me to set a key that expires, is there a multi-set version of this command that also has a TTL?

both MSET and MSETNX commands do not have such an option.

Answer

unreal picture unreal · Dec 18, 2013

I was also looking for this kind of operation. I didn't find anything, so I did it with MULTI/EXEC:

MULTI
expire key1
expire key2
expire key3
EXEC