Home > Backend Development > PHP Tutorial > PHP does not rely on the system automatic execution mechanism, the php system automatic mechanism_PHP tutorial

PHP does not rely on the system automatic execution mechanism, the php system automatic mechanism_PHP tutorial

WBOY
Release: 2016-07-12 08:53:18
Original
913 people have browsed it

PHP does not rely on the system's automatic execution mechanism. The PHP system's automatic mechanism

does not rely on the system and does not rely on the Yii transaction mechanism. Human triggering is considered. The trigger can be written on the overall public page, but considering the pressure on the database and WWW server, and the delay problem 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 have stored the task queue in the cache file ), if there is no need to update, you only need to sort the execution queues in the cache file by time, 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 manually deleted or expired over time, so first check whether the cache file exists each time (generate caches separately by task/user/type), if not, re-query the database , 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.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1125065.htmlTechArticlePHP does not rely on the system automatic execution mechanism, the php system automatic mechanism does not rely on the system, and does not rely on the yii transaction mechanism, then Consider human triggers. Triggers can be written on the overall public page, but...
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