ancoka/yii2-queues
Composer 安装命令:
composer require ancoka/yii2-queues
包简介
A queuning service which is implemented by redis for Yii2 framework.
关键字:
README 文档
README
Yii2-queues is a redis implementation based Yii framework queue extension service. The code is slightly modified on the basis of Chris Boulton's php-resque, using the PSR4 standard, adding namespace support, and inheriting the Yii2 component.
Requirements
- PHP 5.3+
- Redis 2.2+
- Composer
Install
The preferred way to do this is through the composer.
Directly use the composer command to install:
php composer.phar require --prefer-dist soyaf518/yii2-queues "*"
Or add the following to your project's "composer.json" file:
"soyaf518/yii2-queues": "*"
And running:
composer install
Configuration
To use this extension, you have to configure the ResqueComponent class in your application configuration:
return [
//...
'components' => [
'resque' => [
'class' => 'queues\ResqueComponent',
'server' => '127.0.0.1',
'port' => 6379,
'database' => 0,
'user' => '',
'password' => '',
'options' => [
'timeout' => '',
'persistent' => '',
],
],
]
];
Usage
Once the extension is installed, simply use it in your code by :
-
Queueing Jobs
Jobs are queued as follows:
<?php $data = array( 'name' => 'yii-queues' ); # Real-time execution Yii::$app->resque->put('default', $data); # Delayed execution Yii::$app->resque->putIn('default', $data, 10); # Timing execution Yii::$app->resque->putAt('default', $data, 1486620571); -
Defining Jobs
class DefaultWorker { public function setUp() { // ... Set up environment for this job } public function perform() { $data = Yii::$app->resque->getArgs($this->args); // @todo deal with this data } public function tearDown() { // ... Remove environment for this job } } -
Workers
To start a worker:
$ QUEUE=file_serve php bin/resque -
Running All Queues
All queues are supported in the same manner and processed in alphabetical order:
$ QUEUE='*' bin/resque -
Running Multiple Workers
Multiple workers can be launched simultaneously by supplying the COUNT environment variable:
$ COUNT=5 bin/resque
Thanks
- Chris Boulton: php-resque
统计信息
- 总下载量: 23
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-02-09