Redis is it possible to update multiple hset keys(

2019-09-02 21:19发布

问题:

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.

回答1:

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.



回答2:

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.



标签: redis