How can php limit the number of queries per day?

Source: Internet
Author: User
How can php limit the number of queries per day? How can php limit the number of queries per day?

Reply content:

How can php limit the number of queries per day?

Upstairs.
If yesLimit the number of queries per userThe cumbersome method is to write data into the database, which increases sequentially and is cleared at PM. the scheduled task may be used here.
A good method isUser ID + IDAsKeyWrite it into redis.
If it is not based on a single userTotal queriesIn addition to the above two methods, there is also a way to write into the text file, when usedRead,Comparison,+ 1,Write

In fact, what we need to do isValue,Comparison,+ 1,WriteBut the media is different, depending on your needs.
By the way, you can also use it with scheduled tasks if necessary.

Simply put, it is to record a query at a time. There is no difference in the principle of human restricted queries.

Basic idea: query once and database increments once.

When the query volume is large, the performance is naturally bad.

So we can cache Redis and so on, and cache them to the memory at a time to improve efficiency. Update at intervals/a certain number of times

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.