An open API service indexing awesome lists of open source software.

https://github.com/limingxinleo/x-swoole-queue

基于Swoole的多进程消息队列
https://github.com/limingxinleo/x-swoole-queue

processes queue swoole

Last synced: 12 months ago
JSON representation

基于Swoole的多进程消息队列

Awesome Lists containing this project

README

          

# Swoole Queue Library

[![Build Status](https://travis-ci.org/limingxinleo/x-swoole-queue.svg?branch=master)](https://travis-ci.org/limingxinleo/x-swoole-queue)

## 安装
~~~
composer require limingxinleo/x-swoole-queue
~~~

## 基本使用办法
消息队列使用
~~~php
setRedisConfig($host, $auth, $db, $port)
->setPidPath(TESTS_PATH . 'queue2.pid')
->run();
~~~
消息类
~~~php
data = $data;
}

public function handle()
{
File::getInstance()->put($this->file, $this->data);
}
}
~~~
载入消费队列的方法
~~~php
lPush('swoole:queue:queue', serialize($job));
~~~

## 高级使用办法
实现我们自己的消息队列类
~~~php
setRedisConfig($host, $auth, $db, $port);
$this->setPidPath(TESTS_PATH . '/queue2.pid');
}
}
~~~

启动我们的消息队列
~~~php
run();
~~~

载入消费数据
~~~php
msg = $msg;
}

public function handle()
{
echo $this->msg;
}
}

$job = new TestJob('upgrade by test job, when the queue push it!');
$queue = new Queue();
$queue->push($job);
~~~