Ask a question about the inventory of Synchronize in a mall.

topic description

at present, there is a product that the user places an order to reduce inventory, the order is cancelled to increase inventory, and the backend modifies the inventory quantity. There are three different ways to do this. How about Synchronize? Database lock?

topic sources and their own ideas

I wonder if it can be achieved through database optimistic locks, but wouldn"t it be impossible if the version numbers obtained before and after operations within the same transaction are the same? Write a special method to get the version number?

do you have a boss to give me ideas?

Jun.26,2021

what if you do it for me
button operation:
1.redis button
2. Asynchronous message update database
release / update operation
1. Update table
2. Synchronize / Asynchronous Update redis

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-1b35a45-3435d.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-1b35a45-3435d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?