How to prevent duplicate submission

When the user clicks the submit button twice in a row, if no measures are taken, there will be two pieces of data in the data.

Solution: check when inserting database. Insert a distributed lock on the database in the code. Use redis as the object of the lock. After locking, make a judgment. The short rule is to look up a piece of data from the database. If the data does not exist, insert it and generate an ID in the database. If it exists (insert the second data), take out this data and update it. In this way, the problem of repeated insertion can be solved.

Existing problems: it is not clear whether it is a duplicate submission or a user’s update operation


Read More: