Can redis pipeline multiple commands that depend on previous ones?

回眸只為那壹抹淺笑 提交于 2019-12-09 16:45:29

问题


I'm very very new to redis and still playing around with it. I want to test to see if its relevant to my project but I'm not sure about a specific command I'm running. The users on SO have got me convinced of the performance benefits of using pipelines and transactions so I thought I'd ask how to do this.

Basically I have two statements that I just want to issue and not have to wait for the result(seems like a good candidate for pipe lining. It looks like this:

Does valueX exist?
If it does insert valueY

Its pretty simple but so far all the ways I have been looking into it seem to wait for a response for if ValueX exists, and because I'm doing over a billion loops of my program it grinds it to a halt.

Is this possible? If it helps I'm using Java but haven't settled on which client library(jedis or jredis, still testing). I'm actually not even fully settled on redis but leaning very heavily towards it(seems good for what I'm doing speed wise), so any suggestions are acceptable.


回答1:


No, it is not possible for the moment to accomplish such a thing. What you seek is a feature missing for the moment, but it will be available with the 2.6 version of Redis. It's called LUA scripting. You can execute server commands that are dependent of previous commands, all in one, without the need to fetch them at the client. For more details see here.



来源:https://stackoverflow.com/questions/9612743/can-redis-pipeline-multiple-commands-that-depend-on-previous-ones

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!