I am a newbie. I am making a purchase function. When there is only one item left but two people purchase it at the same time, how should I handle this situation? I only learned about Redis a few hours ago using the TP5 framework. I really don’t know how to use TP5. Is there any way to deal with this situation? I hope there are detailed examples and ideas. My own idea is similar to a queue. Two people click at the same time, one by one. deal with
The focus of your question should be shifted to --->Message queue, redis is just one of the methods
When there is one item left, they can all join the shopping. When the actual purchase is made, check the database and give a prompt if the goods are insufficient
Set up a REDIS server and change the cache to redis