Concurrency restrictions on panic buying or seconds killing

for a key daily maximum limit, such as key axiom 100;
can succeed if it is less than 100.
use redis as storage
if the concurrency is relatively large, the program logic first determines whether the value of key is less than 100, and then the value of key may exceed 100 when operating key,. Is there any simple way to avoid it?

Mar.07,2021
The atomic increment of

INCR returns the incremented value. When the request comes, you incr directly. If it is less than 101, it will operate. If it is greater than 101, it will not operate


self-incrementing key or use the queue.

Menu