Redis is it possible to update multiple hset keys(

2019-09-02 21:14发布

Is there a way to use MSET for HSET keys ? I am trying to update multiple HSET keys(not fields) in a single operation to save on network traffic.

标签: redis
2条回答
Viruses.
2楼-- · 2019-09-02 21:41

No and yes.

No, MSET does not support this behavior, nor does Redis have a command to do that.

Yes, it is possible to update multiple Hash keys with a single command to reduce network traffic - the way to do it is with Lua scripting.

查看更多
霸刀☆藐视天下
3楼-- · 2019-09-02 21:56

To save on network trips, you'll want to use pipelining. Using Lua is possible, but not as tunable as pipelining where you can find and set the optimum number of commands per execute for your dataset.

And as an added bonus you get experience with a re-usable technique.

查看更多
登录 后发表回答