Currently, a function is being developed. This function will be triggered when I click the "save" button on the page for setting parameters. Considering this function, different ID parameters need to be sent cyclically to request data from the interface, and then each loop updates the phase of the local database according to the obtained data... currently, a function is being developed. This function will be triggered when I click the "save" button on the page for setting parameters.
Considering this function, different ID parameters need to be sent cyclically to request data from the interface, then, each loop updates the related fields of the local database based on the obtained data (this loop request may have a large number of times and may be thousands of times in the future )...... How can I ensure that this loop operation will be completed due to network latency, blocking, and other issues?
Reply content:
Currently, a function is being developed. This function will be triggered when I click the "save" button on the page for setting parameters.
Considering this function, different ID parameters need to be sent cyclically to request data from the interface, then, each loop updates the related fields of the local database based on the obtained data (this loop request may have a large number of times and may be thousands of times in the future )...... How can I ensure that this loop operation will be completed due to network latency, blocking, and other issues?
Database transactions and multiple SQL statements in a transaction can be rolled back if one fails.
Since you know that you want to request multiple interfaces, we recommend that you change the request to one time. we recommend that you use cache for a lot of requested data and use a queue for asynchronous database transaction operations.