php - Cached mysql inserts - Preserving Data integrity -


I want to do a lot of inserts, but updating mysql after a while is possible.

For example if there is a question like

  update views_table SET view = scene + 1 WHERE id = 12;   

Probably it can not be possible to store this query unless the idea increases to 100 and then run the following instead of running more than 100 times the query.

  Update views_table SET view = View + 100 WHERE id = 12;   

Now, say that this has been done, then there is a problem of data integrity. Let's say, 100 files are open about running the same query. As long as there is no locking mechanisms for enhancing cached ideas, it is likely that many files may have similar value to the cached view, so that the process 1 can have 25 cached ideas and php process 2 There can be 25 views and process 3 in the file can have 27 views. Now the process is said to end 3 and the counter increases to 28. It is then said that the PHP process is over and this procedure is completed immediately after 3, which means that the counter will be brought back to 26.

Do you have any solutions that are fast, but the data is also safe.

Thanks

Unless your query relative By using visible = scene + 5 , then there should be no problem .

Only if you store the price elsewhere in your script, and then calculate your new value, then you can get in trouble. But why do you want to do this? Actually, why do you want to do this in the first place? :)

If you do not want to overload the database, you can use the UPDATE LOW_PRIORITY table set ... , keep the updated action in a queue and will wait the table Now reads or inserts.

Comments