I know that redis is single threaded and two threads cant get/put simultaneously. My concern is that i want to lock the key while thread 1 is getting, updating and putting back data for a key in redis. I dont want to add the three operations in a synchronized block in my application because that will block all threads working on different keys. So I see below happening with my app right now -
1. thread1 gets the key (say value=1)
2. thread2 gets the key (say value=1)
3. thread1 increments value and commits new data to key (value=2)
4. thread2 increments value and commits new data to key (value=2)
I want to lock on the specific key such that at the end of both threads work, the value=3 not 2. I hope I'm clear now. Given this information, can someone please review my questions again and comment?