There are 100 items, and 1,000 requests poured in. The first 200 requests are retained, and the last 800 requests are returned directly.
Of these two hundred requests, only one hundred orders were successfully placed in the end.
Do these two hundred requests directly generate orders according to the queue?
But don’t you need to check the address and other information before generating an order?
How should the entire process be handled?
迷茫2017-05-19 10:10:49
Instead of directly generating an order, the so-called queue means putting tickets in it and buying with the tickets! It can all be the number 1, or it can be replaced by something else! Redis is single-threaded, and dequeueing is done in a first-come-first-served basis. It returns false when the queue is empty. As long as the user gets the ticket, he can immediately put the product into the user's shopping cart and go directly to the normal shopping process!
迷茫2017-05-19 10:10:49
No queuing/locking until the last step. . At the beginning, you fill in the information. In the last step, you need to lock it when submitting the inventory. The simple thing is memcache add. If it is more complicated, use the queue to process it