A good way to get the current progress in a loop on other pages
Source: Internet
Author: User
A good way to get the current progress in a loop on other pages may be a little general about the subject, and the requirement is as follows. There is a group Mail function. Sometimes it may be sent to several hundred customers in a group, so it takes several hundred cycles. At the same time, there is also a page to view the sending progress in real time, and the number of sent messages is dynamically displayed. The process IDs are different for each sent mail. Currently, the processing logic of the displayed page is a good way to get the current progress in a loop through regular ajax query of the email table that belongs to this other page.
The question may be a little general, and the requirement is as follows.
There is a group Mail function. Sometimes it may be sent to several hundred customers in a group, so it takes several hundred cycles. At the same time, there is also a page to view the sending progress in real time, and the number of sent messages is dynamically displayed. The process IDs are different for each sent mail.
Currently, the processing logic of the displayed page is to query the total number of process IDs in the mail table through ajax timing, and then return to the displayed page. The efficiency is too low. Send a query once. Is there any other good way?
I tried to write the current number of cycles into the Session in a loop, and then display the page to read the Session value directly, but each time the final result is displayed.
I am not very familiar with php threads. Please advise.
Share:
------ Solution --------------------
Is memchache or other caches useful? write cache in cyclic scripts; display page ajax request background read cache
------ Solution --------------------
There is no good way. We do not recommend that you make complex operations. It is recommended that you still use ajax + database to obtain the progress. although it is not so real-time, it is enough to meet the engineering requirements. You can use multiple threads to send emails, which is much more efficient.
Otherwise, do not use multithreading. it is simpler to use. Multiple php files can be started for sending through http: // localhost/xxx. php.
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