Redis 更新是同步的吗? [英] Are Redis updates synchronous?

查看:41
本文介绍了Redis 更新是同步的吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我将某些内容推送到 Redis 中的列表中,然后从该列表中弹出,是否可以保证我会得到我之前推送的项目,或者是否有可能在写入之前进行读取?

If I push something onto a list in Redis, then pop from that list, is it guaranteed that I will get the item I pushed earlier or is it possible for the read to happen before the write?

推荐答案

Redis 在单线程中运行(除了在进行后台保存时分叉,但这无关紧要),因此您稍后发送的任何请求都会一定要晚点跑.因此,您将看到您推送的价值.

Redis runs in a single thread (with the exception of forking when doing background saves, but that doesn't matter), so any request that you send later will necessarily run later. Thus, you will see the value that you pushed.

(虽然,再想一想,如果您不愿意并致力于故意使其失败,则可能会引发失败.但这需要通过单独的连接发送您的请求,这不会发生在正常操作中意外.)

(Though, on a second thought, it is probably possible to provoke a failure, if you are ill inclined and dedicated to make it fail on purpose. But that would require sending your requests via separate connections, which doesn't happen accidentially in normal operation.)

这篇关于Redis 更新是同步的吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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