56

How does Redis handle multiple threads (from different clients) updating the same data structure in Redis ? What is the recommended best practice for such a use case?

Soumya Simanta
  • 11,523
  • 24
  • 106
  • 161
  • See http://stackoverflow.com/questions/10489298/redis-is-single-threaded-then-how-does-it-do-concurrent-i-o/10495458#10495458 – Didier Spezia Jun 14 '13 at 11:01

1 Answers1

105

if you read the Little redis book at some point this sentence comes.

"You might not know it, but Redis is actually single-threaded, which is how every command is guaranteed to be atomic. While one command is executing, no other command will run."

Have a look in http://openmymind.net/2012/1/23/The-Little-Redis-Book/ for more information

Regards

andrefsp
  • 3,580
  • 2
  • 26
  • 30
  • 5
    @Juggernaut You would use asyncio if you don't want your python code to block on redis calls. Asyncio is just a non-blocking python library and not a library to manage any transactional or concurrency database problem. Essentially, asyncio_redis and redis are on two different layers on your stack and therefore they are not mutually exclusive. If your application is using redis and you want to make your redis calls asynchronous you should still use asyncio_redis. Hope this helps. – andrefsp Mar 06 '17 at 11:39
  • I guess you can provide an answer here @andrefsp http://stackoverflow.com/questions/42597328/redis-block-untill-key-exists – Amin Etesamian Mar 06 '17 at 11:43