开发者

Are Redis updates synchronous?

开发者 https://www.devze.com 2023-03-10 22:24 出处:网络
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开发者_如何学Go write?R

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开发者_如何学Go write?


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

0

精彩评论

暂无评论...
验证码 换一张
取 消