stackexchange.redis lpop处于发布/订阅-潜在竞争条件?

soat7uwm  于 2021-06-08  发布在  Redis
关注(0)|答案(0)|浏览(224)

在使用dotnet core中的stackexchange.redis库时,我考虑使用pub/sub功能来实现阻止某些工作类使用消息,如下所述。
示例如下:

sub.Subscribe(channel, delegate {
    string work = db.ListRightPop(key);
    if (work != null) Process(work);
});
//...
db.ListLeftPush(key, newWork, flags: CommandFlags.FireAndForget);
sub.Publish(channel, "");

如果多个工人订阅 channel (在一个分布式系统中,不是在同一个主机上)是否仍然存在潜在的竞争条件 ListRightPop 因为它不是redis集群上的阻塞操作?

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题