Stackexchange.redis 缺少“WAIT"支持 [英] Stackexchange.redis lacks the "WAIT" support

查看:47
本文介绍了Stackexchange.redis 缺少“WAIT"支持的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在负载均衡器后面有 3 个 web api 服务器,客户端应用程序正在使用该服务器.我正在使用这个库来访问一个主节点和几个从节点的 redis 集群.当前不支持WAIT"操作,我需要此功能来存储新创建的用户会话并等待它复制到所有从属设备以确保来自客户端的所有后续传入调用读取会话(可能会出现)从我的其他应用程序服务器)不会失败(因为它可以尝试从 redis slave 读取密钥).

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.

推荐答案

WAIT 本质上是一个阻塞操作,它违反了库所依赖的连接共享编程模型(查看更多此处).所以不,这没有暴露.

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".

您可以通过 Execute 手动发布它,但是如果您这样做:您自己;如果它爆炸或引起任何问题......玩得开心!

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();

这篇关于Stackexchange.redis 缺少“WAIT"支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆