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 to do it

Source: Internet
Author: User
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

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.