定制 yarcode/yii2-daemon 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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
  • 点击次数: 1
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 4
  • Watchers: 3
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-07-28