Queue Introduction

The Easyswoole package implements a lightweight queue, with Redis as the queue driver by default.

You can implement a queue driver yourself to implement queue storage in kafka or boot mode.

As you can see, Queue is not a separate component, it is more like a facade component that uniformly encapsulates different driver queues.

start installation

Composer require easyswoole/queue


  • Register queue driver
  • Set the consumption process
  • Producer delivery task

Redis driver example

use EasySwoole\Redis\Config\RedisConfig;
use EasySwoole\RedisPool\RedisPool;
use EasySwoole\Queue\Driver\Redis;
use EasySwoole\Queue\Queue;
use EasySwoole\Queue\Job;

$config = new RedisConfig([
$redis = new RedisPool($config);

$driver = new Redis($redis);
$queue = new Queue($driver);

go(function ()use($queue){
    while (1){
        $job = new Job();
        $id = $queue->producer()->push($job);
        var_dump('job create for Id :'.$id);

go(function ()use($queue){
    $queue->consumer()->listen(function (Job $job){