简体   繁体   中英

Is it possible to set expiry to redis keys (bulk operation)

I am using mget(keys, *args) to bulk set keys.
I also want to set expiration time to keys. The reason I am using mset is to save calls to redis.
Is there a way to bulk set keys with expiration ?
Thanks.

There is no command that sets the TTL for multiple keys, in the fashion that MSET works. You can, however, replace the call to MSET with a Lua script that does SETEX for each key and value passed to it as parameters.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM