How does this logic implement the countdown to changing the order status for n hours?

Source: Internet
Author: User
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.

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.