- each user"s record in the order table of the database has 15 states ( 12 status codes represent on-the-way status, 3 status codes represent final status ). The state between
- data can be transferred.
- requires that the active status of the same user can have only one record, and the final state can have more than one record.
- how to ensure data integrity
- Code flow: query the data before inserting it into the database. If you query the data that the current user is not in progress, insert it; if you query the data that the current user has a status in progress, you will not insert it.
- but when the concurrency of the same user is high, it is well known that the data is not rigorous.
- in the case of a single node, Synchronize (synchronized) can be used to solve the problem of data integrity, but when Synchronize is used, it also blocks the operation of all other users, resulting in poor performance.
I expect some great god to come up with a better solution, which is better than Synchronize (synchronized) "s method, and also ensures data integrity.
look forward to!