I have 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?

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

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.