Stackexchange.redis lacks the “WAIT” support

会有一股神秘感。 提交于 2020-01-03 03:13:06

问题


i have 3 web api servers behind a load balancer which a client application is using. i am using this library to access redis cluster with one master and few slaves. the "WAIT" operation is not currently supported, and i need this functionality in order to store a newly created user session and wait until it replicates to all slaves to ensure that all following incoming calls from the client to read the session (which can come from my other application servers) won't fail (as it can try to read the key from a redis slave).

looking for some best practice for such implementation.


回答1:


WAIT is essentially a blocking operation, which violates the connection-sharing programming model that the library depends on (see more here). So no, this isn't exposed.

We are discussing ideas to allow a more versatile pool/lease model as well as the default shared model, but right now: this doesn't exist. But this is what would make blocking commands "safe".

You could issue it manually via Execute, but if you do that: you're on your own; if it explodes or causes any kind of problem... have fun with that!


The following is not supported (essentially it issues a blocking operation), but if it works - it works; if it causes problems - it causes problems:

var tran = db.CreateTransaction();
_ = tran.StringSetAsync("mykey", cacheItem);
_ = tran.ExecuteAsync("wait", 2);
tran.Execute();



回答2:


solved it finally - there was a missing parameter for the wait



来源:https://stackoverflow.com/questions/57871559/stackexchange-redis-lacks-the-wait-support

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