Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are Redis updates synchronous?

Tags:

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?

like image 548
bmaddy Avatar asked Oct 10 '22 19:10

bmaddy


1 Answers

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

like image 95
Damon Avatar answered Oct 20 '22 14:10

Damon