Is a program scheduled to run on the server? Or do I need to modify it after the page is accessed? Is a program scheduled to run on the server?
Or do I need to modify it after the page is accessed?
Reply content:
Is a program scheduled to run on the server?
Or do I need to modify it after the page is accessed?
I don't think real-time update is necessary. I think it is better to record an expiration time when creating an order, therefore, when reading this order, you only need to judge whether the timestamp has expired and whether the current status can be continued. scheduled tasks and other tasks are not a good strategy, let's not talk about the efficiency of using php to interact with the system level, but the risk of exceptions in the intermediate program is not very controllable. In addition, when there are large orders, the server load is also very high.
You can use a scheduled script based on your logic. Otherwise, it is not a real-time change during each access, and the efficiency is still low.
You can use a linux system to schedule tasks without repeating
If websocket is not used on your browser, you can check whether the websocket expires when there is access;
If websocket is used, you can run the cron honestly ~
Depends on the specific business scenario requirements.
Is it similar to the function of canceling the order without payment within 15 minutes? I have never done it, so I can only talk about it. When an order is generated, PHP calls the system function operation to create a task that will be executed 15 minutes later. The task statement is dynamically generated, for example, php-f checkOrderStatus. php-id 323003.
In checkOrderStatus. php, the system function is also used to delete this scheduled task (if there is a one-time scheduled task, there is no need to worry about it. In fact, I don't understand Linux and only search for information when using it.
As for @ accyl, you don't have to worry too much about the load problem. because this function does not go through web services, the cost of executing this file is much lower than that of creating an order, order can be processed.