PHP code example of icy8 / queue

1. Go to this page and download the library: Download icy8/queue library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

icy8 / queue example snippets


   
   
   use icy8\Queue\Listener;
   use Symfony\Component\Process\PhpProcess;
   
   
   $listener->execInterval = '0.1';
   // 定制自己的消费进程
   /*$listener->makeProcess('
   // 为redis配置密码
   $exec = new \icy8\Queue\Executor("redis", ["port"=>"6399", "password"=>"123456"]);
   $exec->runNext();');*/
   // 开始监听队列
   $listener->run();
   

   
   
   = new \icy8\Queue\connector\Redis();
   $connection->init();
   // 任务立即执行
   $connection->push(\icy8\Queue\test\JobTest::class, ['a', 'b', 'c']);
   // 运行任务类的自定义方法
   $connection->push([\icy8\Queue\test\JobTest::class, 'custom'], '自定义方法');
   // 延迟任务
   $connection->pushDelay(\icy8\Queue\test\JobTest::class, ['a', 'b', 'c'], 3);