PHP limit a certain amount of query per day, how to achieve it?

Source: Internet
Author: User
PHP limit a certain amount of query per day, how to achieve it?

Reply content:

PHP limit a certain amount of query per day, how to achieve it?

Upstairs positive solution.
If it is a single-user limit query volume , cumbersome method is to write into the database, ascending, 12 o'clock Zero, clear 0 here may need to use the scheduled task.
A good way to do that is to 用户ID+标识 key write into Redis.
If the limit is not based on a single user, but based on the total number of queries to limit, in addition to the above two methods are written into the text file, when used,,, 读取 比较 +1写入

In fact, the combination of the above, nothing but the action is,,,, 取值 比较 but the media is +1 写入 not the same, depending on the demand.
Yes, it can also be used with timed tasks if needed.

Simply put, that is the query once a write. There is no difference between the principle of human restriction and inquiry.

Basic idea: Query once, database increment once.

A large amount of query performance will naturally suck.

It's like Redis, and every increment is cached into memory to improve efficiency. Updated 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.