在我当前的任务中,当我选择大量记录然后更改它们的状态或重新分配它们时,系统可能会慢到那个点,因此用户必须等待一段时间才能完成此操作。
那么有没有办法将此进程放入队列中,以便该进程在后台运行并且用户可以执行其他任务。
提前谢谢你。
是的......看看Gearman:
http://gearman.org/index.php?id=getting_started
http://php.net/manual/en/book.gearman.php
Alternativley,如果你不喜欢,我已经多次使用这个优秀的 4 部分教程的原理,效果很好:
Need more information on how the queue is processed, you mean that the data that is being processed has nothing to do with the second process running after the first process? In that case I would run your script as
yourcommand > /dev/null 2>&1 &
this would let the process run in the background.
In the context of PHP, if it is speed that you are after, I would check if PHP has enough memory available. If yes, I would save the values in an array and use a foreach loop to manipulate data. Usually this works out faster.
More information is required.
Hari
是肯定的。如果您想让 php 脚本在后台执行它,并让用户玩您的网站。您需要做的就是发送标头:
header("Connection: close");
header("Content-length: $size");
是你要找的吗?
使用j-query ajax 方法并让用户等待而不进行任何操作。