Is the simple implementation of locking for a single instance of redis reliable?

for example, iphone rewards are given if the judgment key does not exist, and the key is set immediately after the code is entered, so that multiple users will not all get the prize. I wonder whether the concurrency is high enough or there is a probability that multiple user judgment keys do not exist at the same time, so that a lot of prizes will be issued.

Apr.28,2021

No, redis is single-threaded. The operations of multithreaded programs do not exist concurrency in redis . Once you have the winning key, other threads will access it again.


depends on what command you use, you will definitely use get, and you will not use the setnx command

.
Menu