I made a voting project, do not want to every vote to visit a database, want to update the database after a certain time, how should I do?
I made a voting project, do not want to every vote to visit the update database, want to update the database after a certain time, how should I do? Database Delay Delay vote
Share to:
------Solution--------------------
The more straightforward way I can think of is:
Writes the result of the poll to a text file, either as an SQL statement (recommended) or as a simple dump of the data.
Run a cron job in the background, scan the software every minute, and filter what needs to be updated to the database with some markup (such as the maximum Id,timestamp last processed).
------Solution--------------------
The voting results can be divided into an array of time periods, the array to write a temporary file, every time to extract the file, and then empty the file, with the 4 floor of the idea of the same!
------Solution--------------------
How about using caches like memcache?
Bulk read and write to database at a time and empty memcache
------Solution--------------------
I suggest you write the database directly.
The concurrency of a file is actually not good to handle.
And from the point of view of reading files and databases, I think the database is more convenient