yarcode/yii2-daemon
最新稳定版本:0.3.1
Composer 安装命令:
composer require yarcode/yii2-daemon
包简介
Yii2 daemon based on ReactPHP
关键字:
README 文档
README
Yii2 daemon based on ReactPHP
Installation
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist yarcode/yii2-daemon
or add
"yarcode/yii2-daemon": "*"
Usage
Extend the YarCode\Yii2\Daemon\DaemonCommand class and add your own prepare() implementation.
<?php
namespace console\controllers;
use YarCode\Yii2\Daemon\DaemonCommand;
class AsyncController extends DaemonCommand
{
public function prepare()
{
$this->loop->addPeriodicTimer(1, function() {
\Yii::$app->db->createCommand('SELECT 1')->execute();
});
$this->loop->addPeriodicTimer(0.1, function() {
while ($task = \Yii::$app->async->receiveTask('search')) {
if ($task->execute()) {
\Yii::$app->async->acknowledgeTask($task);
}
}
});
}
}
统计信息
- 总下载量: 6.03k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 0
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-07-28