Home > front end >  About redis minus inventory problem!!!!!! Often ask the interview, a big pit! Is there a big
About redis minus inventory problem!!!!!! Often ask the interview, a big pit! Is there a big

Time:09-25

Common process is minus inventory first, then to MQ, and then determine whether oversold, and then written to the database (the only index to prevent repeated),
Redis inventory 10, mysql inventory ten, but now one sent 10 seconds kill, redis=0 mysql=10, a redis success=0, mysql=9.
So others can not seconds killed, and only sell a commodity,

CodePudding user response:

This idempotence, i.e., the same operation, no matter how many times repeatedly, the result should be consistent,
Sent back to you this question, one of 10 seconds to kill, it should be equivalent to sending a second, then you should record in redis once the user of a unique identifier, to identify if it made seconds kill activity,
Seconds kill success, the same mysql also should make records, avoid service restart causes such as cache misses, repeated down the situation,
  • Related