Search code examples
rediskey-value-storettl

Redis Multi-Set With a TTL


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.


Solution

  • 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