当前位置:网站首页>Instructions for laravel8 Beanstalk

Instructions for laravel8 Beanstalk

2022-06-23 13:58:00 Squatting in the corner counting ants

Xiaobian uses laravel 8 Version

1、 Use composer Load component library , If the version number is not specified, the latest version will be installed by default , Configure after installation

composer require pda/pheanstalk

2、 To configure beanstalk service , Here, Xiaobian picks the configuration to env In the middle

#beanstalk  queue 
BEANSTALKD_HOST=127.0.0.1

3、put Data usage , Don't talk about code directly

// Let's start with the class 
use Pheanstalk\Pheanstalk;

// Create links 
$pheanstalk = Pheanstalk::create(env('BEANSTALKD_HOST'));
// Choose a pipeline to store data 
$pheanstalk->useTube(' Pipe name ( Self defined )')->put(json_encode($info));
$res = $pheanstalk->stats();
if (empty($res) || !isset($res['name']) || $res['name'] != 'OK') {
	// Call the police 
}

4、 obtain beanstalk Pipeline data

// Let's start with the class 
use Pheanstalk\Pheanstalk;

// Create links 
$pheanstalk = Pheanstalk::create(env('BEANSTALKD_HOST'));
// Select pipe 
$pheanstalk->watch('yunDuoDataList');
// Set link timeout 
$job = $pheanstalk->reserveWithTimeout (3);
if (!$job) {
    return false;
}
// get data 
$beanstalkStr = $job->getData();
if (empty($beanstalkStr)) {
    return false;
}
// Analyze data for business use 
$beanstalkInfo = json_decode($beanstalkStr, true);

5、 Common method reference

beanstalk Common methods 、 explain _ Squatting in the corner counting ants' blog -CSDN Blog

原网站

版权声明
本文为[Squatting in the corner counting ants]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/174/202206230943589742.html