I made a voting project. I don't want to access the database every time I vote. what should I do if I want to update the database after a certain period of time? I made a voting project. I don't want to access and update the database every time I vote. what should I do if I want to update the database after a certain period of time? I made a voting project for the database. I don't want to access the database every time I vote. what should I do if I want to update the database after a certain period of time?
I made a voting project. I don't want to access and update the database every time I vote. what should I do if I want to update the database after a certain period of time?
Database delayed voting
Share:
------ Solution --------------------
The direct method I can think of is:
Write the voting result into a text file in the format of SQL statement (recommended) or simple dump of data.
The background runs a cron job, scanning the software every minute, and filtering the content to be updated to the database with some tags (such as the largest ID and timestamp processed last time.
------ Solution --------------------
You can save the voting results to an array in different time periods. the array is written into a temporary file, the file is extracted at intervals, and the file is cleared, which is similar to the idea on the fourth floor!
------ Solution --------------------
How is cache used, such as memcache?
Read and write data to the database in batches within a period of time, and clear memcache at the same time.
------ Solution --------------------
I suggest you write data directly to the database.
File concurrency is not easy to handle.
In addition, from the perspective of reading files and databases, I think the database is more convenient.