Are redis operations on data structures thread safe

18,910

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

Share:
18,910

Related videos on Youtube

Soumya Simanta
Author by

Soumya Simanta

Updated on October 09, 2022

Comments

  • Soumya Simanta
    Soumya Simanta 3 months

    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?

  • andrefsp
    andrefsp almost 6 years
    @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.
  • Juggernaut
    Juggernaut almost 6 years
    I guess you can provide an answer here @andrefsp stackoverflow.com/questions/42597328/…