Home > Backend Development > PHP Tutorial > PHP does not rely on the system's automatic execution mechanism. PHP from entry to proficiency. Shijiazhuang PHP training institution. PHP tutorial video for free.

PHP does not rely on the system's automatic execution mechanism. PHP from entry to proficiency. Shijiazhuang PHP training institution. PHP tutorial video for free.

WBOY
Release: 2016-07-29 08:50:27
Original
891 people have browsed it

If it does not rely on the system or the Yii transaction mechanism, human triggering will be considered. The trigger can be written on the overall public page, but considering the pressure on the database and WWW server and the delay of the program, some optimization of the execution function is required.

First of all, we consider the pressure on the database. Every time we click on the page, we let it trigger the monitoring system. The monitoring system must first determine whether our task queue needs to be updated at this time (I save the task queue in the cache file) , if there is no need to update, you only need to time-order the execution queues in the cache file, and execute the queues that have timed out. But we need to consider when to update the queue file and how to update it, so as to reduce the pressure on the system.

My idea is, first of all, the cache file may be deleted manually or expire after timeout. Then check whether the cache file exists each time (generate caches separately by task/user/type). If it does not exist, query the database again. Generate cache files (those that have timed out are executed directly, and those that are unsuccessful are thrown into the cache queue).

The next step is for each access. If there is a cache file, first process the timeout task in the file, and then update the cache file. At this time, we encounter a problem, which is the impact on the cache queue during operation. We may need to insert the queue to be executed at the beginning or somewhere in the middle of the cache queue. In this case, we can manually delete the existing queue. The next time it is triggered, because the cache file cannot be found, the latest cache queue will be regenerated.

When we finish executing a task, the entry in the queue will be deleted. If the queue is empty, the query will be re-queried and the queue will be generated, thus ensuring the minimum number of accesses to the database. There is another problem, such as the monitoring of automatic confirmation of receipt of orders. If it is an update to the user's front desk, it is necessary to delete the cache of this user and the cache of the back-end administrator to which the user belongs, so as to ensure that relevant personnel are browsing the order. , all you see is the latest status. In the same way, the backend administrator's modification order should also delete the cache queue of all relevant personnel at the same time.

The above has introduced PHP's automatic execution mechanism that does not rely on the system, including PHP, mechanism aspects. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template