AI助手支持GPT4.0
Async Background Worker, more information please visit this page https://异步后台工作者,更多信息,请访问此页面 https:// tonjoo.github.io/async-background-worker/tonjoo.github.io/async-background-worker/ p>
异步后台工作者,更多信息,请访问此页面 https:// tonjoo.github.io/async-background-worker/
tonjoo.github.io/async-background-worker/
WordPress background worker plugin that enable WordPress to interact with beanstalkd work queue.
WordPress后台工作人员插件,使WordPress可以与beantalkd工作队列进行交互。 p>
We can run a very long task in the background, for example we need to import 100.000 row into WordPress databases.
我们可以在后台运行很长的任务,例如,我们需要将100.000行导入WordPress数据库。
Instead of doing the 100.000 import in one job, we can separate the job into many smaller job which is safer.
除了将10万个工作导入一个工作之外,我们还可以将工作分为许多更安全的较小工作。 p>
Make sure you have WP CLI installed on your system
确保系统上已安装WP CLI p>
https://forum.tonjoostudio.com/ https://forum.tonjoostudio.com/ thread-category/async-background-worker/thread-category / async-background-worker / p>
https://forum.tonjoostudio.com/ thread-category/async-background-worker/
thread-category/async-background-worker/
thread-category / async-background-worker /
Add new job to new worker queue using add_async_job command
add_async_job
使用 add_async_job code>命令将新作业添加到新的工作人员队列 p>$job = new stdClass(); $ job = new stdClass();// the function to run//要运行的函数$job->function = 'function_to_execute_on_background';$ job-> function ='function_to_execute_on_background';// our user entered data//我们的用户输入的数据$job->user_data = array('data'=>'some_data');$ job-> user_data = array('data'=>'some_data');add_async_job($job);add_async_job($ job); code> pre>
add_async_job code>命令将新作业添加到新的工作人员队列 p>$job = new stdClass(); $ job = new stdClass();// the function to run//要运行的函数$job->function = 'function_to_execute_on_background';$ job-> function ='function_to_execute_on_background';// our user entered data//我们的用户输入的数据$job->user_data = array('data'=>'some_data');$ job-> user_data = array('data'=>'some_data');add_async_job($job);add_async_job($ job); code> pre>
$job = new stdClass(); $ job = new stdClass();// the function to run//要运行的函数$job->function = 'function_to_execute_on_background';$ job-> function ='function_to_execute_on_background';// our user entered data//我们的用户输入的数据$job->user_data = array('data'=>'some_data');$ job-> user_data = array('data'=>'some_data');add_async_job($job);add_async_job($ job); code> pre>
$ job = new stdClass();// the function to run//要运行的函数$job->function = 'function_to_execute_on_background';$ job-> function ='function_to_execute_on_background';// our user entered data//我们的用户输入的数据$job->user_data = array('data'=>'some_data');$ job-> user_data = array('data'=>'some_data');add_async_job($job);add_async_job($ job);
// the function to run
//要运行的函数
$job->function = 'function_to_execute_on_background';
$ job-> function ='function_to_execute_on_background';
// our user entered data
//我们的用户输入的数据
$job->user_data = array('data'=>'some_data');
$ job-> user_data = array('data'=>'some_data');
add_async_job($job);
add_async_job($ job);
code> pre>
li>
Implement function
执行功能 p>
function function_to_execute_on_background($data) { function function_to_execute_on_background($ data){ //do something usefull //做一些有用的事情 echo "Background job executed successfully\n";回显“后台作业成功执行\ n”;}} code> pre>
function function_to_execute_on_background($ data){ //do something usefull //做一些有用的事情 echo "Background job executed successfully\n";回显“后台作业成功执行\ n”;}}
//do something usefull
//做一些有用的事情
echo "Background job executed successfully\n";
回显“后台作业成功执行\ n”;
}
Run wp background-worker listen
wp background-worker listen
运行 wp后台工作者监听 code> p>
wp后台工作者监听 code> p>
ol>
wp background-worker
wp后台工作者 code> Run Async Background Worker once.一次运行异步后台工作程序。 p>
Run Async Background Worker once.
一次运行异步后台工作程序。 p>
wp后台工作者监听 code> Run Async Background Worker in loop (contiously), this is what you want for background worker.(连续)循环运行Async Background Worker(连续地),这就是您想要的Background Worker。 WordPress framework is restart in each loop.WordPress框架会在每个循环中重新启动。 p>
Run Async Background Worker in loop (contiously), this is what you want for background worker.
(连续)循环运行Async Background Worker(连续地),这就是您想要的Background Worker。
WordPress framework is restart in each loop.
WordPress框架会在每个循环中重新启动。 p>
wp background-worker listen-daemon
wp后台工作者监听守护程序 code> Run Async Background Worker in loop (contiously) without restart the WordPress framework.循环(连续)运行Async Background Worker(连续地),而无需重新启动WordPress框架。 NOTE if you use this mode, any code change will not be reflected.注意 strong>(如果使用此模式,则不会反映任何代码更改)。You must restart the Async Background Worker each time you change code.每次更改代码时,都必须重新启动“异步后台工作器”。This save memory and speed up thing.这样可以节省内存并加快速度。 p>
Run Async Background Worker in loop (contiously) without restart the WordPress framework.
循环(连续)运行Async Background Worker(连续地),而无需重新启动WordPress框架。
NOTE if you use this mode, any code change will not be reflected.
注意 strong>(如果使用此模式,则不会反映任何代码更改)。You must restart the Async Background Worker each time you change code.每次更改代码时,都必须重新启动“异步后台工作器”。This save memory and speed up thing.这样可以节省内存并加快速度。 p>
You must restart the Async Background Worker each time you change code.
每次更改代码时,都必须重新启动“异步后台工作器”。
This save memory and speed up thing.
这样可以节省内存并加快速度。 p>
ul>
原文出处:http://www.sanshu.cn/a/2947.html
群主管理都是支付大佬