当前位置:网站首页>Common methods and descriptions of beanstalk
Common methods and descriptions of beanstalk
2022-06-23 13:58:00 【Squatting in the corner counting ants】
Basics
require "vendor/autoload.php"; // Import components
use Pheanstalk\Pheanstalk;// Import components
$ph = new Pheanstalk('127.0.0.1',11301);// Create links Maintenance class
1. View the present pheanStalkd State information
$ph->stats()2. Displays the existing pipeline
$ph->listTubes()3. see NewUsers Pipeline information
$ph->useTube('NewUsers')->put('test');
$ph->useTube('NewUsers')->put('up'); // towards NewUsers Add a... To the pipe up Mission
print_r($ph->statsTube('NewUsers'));// see NewUsers Pipeline information 6. View the status of a task in the specified pipeline
$job = $ph->watch('NewUsers')->reserve(); // Take the task out of the pipeline ( consumption )
print_r($ph->statsJob($job)); // View the status of a task in the specified pipeline 7. View tasks id by 1 Mission details for
$job = $ph->peek(1);// Take out the task directly id by 1 The task of [ notes :beanstalkd For all tasks in id They are all unique ]
print_r($ph->statsJob($job));// View tasks id by 1 Mission details for Production
The first one is put()
$tube = $ph->useTube('NewUsers');// Connect NewUsers The Conduit
print_r($tube->put('four'));// towards NewUsers Pipeline add task four, And return the result notes : put() There are ways 3 Optional parameters ( In turn : priority priority, Delay time delay, Task timeout resend ttr)
The second kind putInTube() [ notes : putInTube() That's right useTube() and put() Encapsulation ]
$res = $ph->putInTube('NewUsers','three');// towards NewUsers Pipeline add task three notes : putInTube() There are ways 3 Optional parameters ( In turn : priority priority, Delay time delay, Task timeout resend ttr)
print_r($res);// Back to task id
print_r($ph->statsTube('NewUsers'));// see NewUsers Details of the pipeline Consumer
1.watch monitor NewUsers The Conduit [ notes : watch() You can also listen to multiple pipelines ]
$tube = $ph->watch('NewUsers');
print_r($ph->listTubesWatched());// Print the pipeline that has been monitored 2.watch Listening to multiple pipes
$tube = $ph->watch('NewUsers')->watch('default');
print_r($ph->listTubesWatched());// Print the pipeline that has been monitored 3.ignore monitor NewUsers The Conduit , Ignore default The Conduit
$tube = $ph->watch('NewUsers')->ignore('default');
print_r($ph->listTubesWatched());// Print the pipeline that has been monitored 4.reserve monitor NewUsers The Conduit , And take out the task
$job = $ph->watch('NewUsers')->reserve();
$job = $ph->reserveWithTimeout (3);// Expiration time second
var_dump($job);// Print the tasks that have been taken out
$ph->delete($job);// Delete the removed task notes :reserve() Yes 1 Parameters , Blocking time , After the blocking time , Whether there is anything or not , Go straight back to .4.0 After version, it is basically abandoned , Change it to reserveWithTimeout (3)
5.putInTube/put towards NewUsers Pipeline write task [ notes : This is the producer method , Put here for easy understanding ]
$ph->putInTube('NewUsers','number_1',5);
$ph->putInTube('NewUsers','number_2',3);
$ph->putInTube('NewUsers','number_3',0);
$ph->putInTube('NewUsers','number_4',4);
print_r($ph->statsTube('NewUsers'));// see NewUsers Pipe details 6.release Put the removed task back ready state , also 2 Parameters ( Priority and delay )
$job = $ph->watch('NewUsers')->reserve();// monitor NewUsers The Conduit , And take out the task
if (true) {
sleep(30);
$ph->release($job);// After taking the task out , Stop 30 second , Then change the task status back to ready
} else {
$ph->delete($job);
}
7.bury ( reserve ) After taking the task out , It is found that the logic executed later is not mature ( E-mail , I suddenly found that the mail server was down ), In other words, the following logic cannot be executed , The task needs to be sealed up first , Waiting for the time to come , Then take out this task for consumption
$job = $ph->watch('NewUsers')->reserve();// Take out the task
$ph->bury($job);// After taking out the task , Put the task aside ( reserve )8.peekBuried() Will be in bury The status of the task is read out
$job = $ph->peekBuried('NewUsers');// take NewUsers In the pipeline bury The status of the task is read out
var_dump($ph->statsJob($job));// Print job status ( The task status should be bury)9.kickJob() Will be in bury The task in task status is converted to ready state
$job = $ph->peekBuried('NewUsers');// take NewUsers In the pipeline bury The status of the task is read out
$ph->kickJob($job);10.kick() Will be in bury The task in task status is converted to ready state , There's a second parameter int, Batch tasks id Tasks less than this number are converted to ready
$ph->useTube('NewUsers')->kick(65);// hold NewUsers Tasks in the pipeline id Less than 65, And the task status is bury All the tasks of are transformed into ready11.peekReady() Place the ready The status of the task is read out
$job = $ph->peekReady('NewUser');// take NewUser In the pipeline, there is ready The status of the task is read out
var_dump($job);
$ph->delete($job);12.peekDelay() Place all in the pipe at delay The status of the task is read out
$job = $ph->peekDelayed('NewUser');
var_dump($job);
$ph->delete($job);13.pauseTube() Set the delay for the entire pipeline , Leave the pipeline in a delayed state
$ph->pauseTube('NewUser',10);// Set up pipes NewUser The delay time is 10s
$job = $ph->watch('NewUser')->reserve();// monitor NewUser The Conduit , And take out the task
var_dump($job);14.resumeTube() Restore pipeline , Leave the pipeline in a non delayed state , Be consumed immediately
$ph->resumeTube('NewUser');// Cancel pipeline NewUser Delay state of , Change to read immediately
$job = $ph->watch('NewUser')->reserve();// monitor NewUser The Conduit , And take out the task
var_dump($job);15.touch() Let task recalculate task timeout resend ttr Time , It is equivalent to prolonging the life of the task
边栏推荐
- 爱思唯尔-Elsevier期刊的校稿流程记录(Proofs)(海王星Neptune)(遇到问题:latex去掉章节序号)
- Hanyuan high tech new generation green energy-saving Ethernet access industrial switch high efficiency energy-saving Gigabit Industrial Ethernet switch
- 有向图D和E
- KDD 2022 | epileptic wave prediction based on hierarchical graph diffusion learning
- 面向 PyTorch* 的英特尔 扩展助力加速 PyTorch
- Simplify deployment with openvino model server and tensorflow serving
- 『忘了再学』Shell流程控制 — 39、特殊流程控制语句
- Generics, generic defects and application scenarios that 90% of people do not understand
- Acquisition of wechat applet JSON for PHP background database transformation
- 【深入理解TcaplusDB技术】一键安装Tmonitor后台
猜你喜欢

Input adjustment of wechat applet

通过 OpenVINO Model Server和 TensorFlow Serving简化部署
![[deeply understand tcapulusdb technology] table management of document acceptance](/img/59/e435623ab9cc7d2aa164c2f08e135f.png)
[deeply understand tcapulusdb technology] table management of document acceptance

【深入理解TcaplusDB技术】单据受理之表管理

实战 | 如何制作一个SLAM轨迹真值获取装置?

【深入理解TcaplusDB技术】Tmonitor系统升级

Actual combat | how to make a slam track truth acquisition device?

How do I turn on / off the timestamp when debugging the chrome console?

深入剖析MobileNet和它的变种

MySQL single database and table splitting using MYCAT
随机推荐
串口、COM、UART、TTL、RS232(485)区别详解
深入剖析MobileNet和它的变种
【深入理解TcaplusDB技术】Tmonitor后台一键安装
[deeply understand tcapulusdb technology] table management of document acceptance
How did Tencent's technology bulls complete the overall cloud launch?
How to use androd gradle module dependency replacement
Go写文件的权限 WriteFile(filename, data, 0644)?
How to use sed -i command
Intel ® extensions for pytorch* accelerate pytorch
Tencent cloud tdsql-c heavy upgrade, leading the cloud native database market in terms of performance
【深入理解TcaplusDB技术】如何实现Tmonitor单机安装
Digraph D and e
Pyqt5 designer making tables
KS003基于JSP和Servlet实现的商城系统
[deeply understand tcapulusdb technology] transaction execution of document acceptance
DBMS in Oracle_ output. put_ How to use line
What a talented company that can turn SAP system into a chicken rib!
OpenVINOTM 2022.1中AUTO插件和自动批处理的最佳实践
Shell process control - 39. Special process control statements
CRMEB 二开短信功能教程