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.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3175d-2b2e2.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3175d-2b2e2.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?