hidalgo-rides/intersect-queue

一个队列处理系统,允许定义并使用单个脚本入口点运行类似于cron的处理程序。

1.0.1 2020-03-01 20:48 UTC

This package is auto-updated.

Last update: 2024-09-29 04:43:31 UTC


README

Intersect Queue是一个队列处理系统,允许使用单个脚本入口点定义和运行类似于cron的处理程序。

变更日志

查看CHANGELOG.md以获取所有已发布的功能/错误修复

通过Composer安装

composer require hidalgo-rides/intersect-queue

使用方法

创建自定义处理器

创建您自己的自定义处理器以执行您想要在重复时间执行的操作

<?php

class SampleProcessor implements \Intersect\Queue\QueueProcessor {
    
    public function getFrequency()
    {
        // every five minutes
        return '*/5 * * * *';
    }

    public function process()
    {
        // do custom things here like query database records to
        // perform actions, update stats, or whatever you want
    }
    
}

使用QueueManager注册和运行处理器

创建一个脚本以初始化QueueManager并注册所有您的自定义处理器

<?php

// initialize QueueManager
$queueManager = new \Intersect\Queue\QueueManager();

// register processor
$queueManager->registerProcessor(new SampleProcessor());

// run QueueManager
$queueManager->run();

设置cron,每分钟调用QueueManager脚本

* * * * * php /path/to/queue/manager/script.php >> /dev/null 2>&1

许可证

Intersect Framework是开源软件,根据MIT许可证授权。