定制 kamisama/php-resque-ex-scheduler 二次开发

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

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

kamisama/php-resque-ex-scheduler

最新稳定版本:1.2.3

Composer 安装命令:

composer require kamisama/php-resque-ex-scheduler

包简介

php-resque-ex-scheduler is a PHP port of resque-scheduler, which adds support for scheduling jobs to PHP-Resque.

README 文档

README

php-resque-scheduler is a PHP port of resque-scheduler, which adds support for scheduling items in the future to Resque.

The PHP port of resque-scheduler has been designed to be an almost direct-copy of the Ruby plugin, and is designed to work with the PHP port of resque, php-resque.

At the moment, php-resque-scheduler only supports delayed jobs, which is the ability to push a job to the queue and have it run at a certain timestamp, or in a number of seconds. Support for recurring jobs (similar to CRON) is planned for a future release.

Because the PHP port is almost a direct API copy of the Ruby version, it is also compatible with the web interface of the Ruby version, which provides the ability to view and manage delayed jobs.

Delayed Jobs

To quote the documentation for the Ruby resque-scheduler:

Delayed jobs are one-off jobs that you want to be put into a queue at some point in the future. The classic example is sending an email:

require 'Resque/Resque.php'; require 'ResqueScheduler/ResqueScheduler.php'; $in = 3600; $args = array('id' => $user->id); ResqueScheduler::enqueueIn($in, 'email', 'SendFollowUpEmail', $args); 

The above will store the job for 1 hour in the delayed queue, and then pull the job off and submit it to the email queue in Resque for processing as soon as a worker is available.

Instead of passing a relative time in seconds, you can also supply a timestamp as either a DateTime object or integer containing a UNIX timestamp to the enqueueAt method:

require 'Resque/Resque.php'; require 'ResqueScheduler/ResqueScheduler.php'; $time = 1332067214; ResqueScheduler::enqueueAt($time, 'email', 'SendFollowUpEmail', $args); $datetime = new DateTime('2012-03-18 13:21:49'); ResqueScheduler::enqueueAt(datetime, 'email', 'SendFollowUpEmail', $args); 

NOTE: resque-scheduler does not guarantee a job will fire at the time supplied. At the time supplied, resque-scheduler will take the job out of the delayed queue and push it to the appropriate queue in Resque. Your next available Resque worker will pick the job up. To keep processing as quick as possible, keep your queues as empty as possible.

Worker

Like resque, resque-scheduler includes a worker that runs in the background. This worker is responsible for pulling items off the schedule/delayed queue and adding them to the queue for resque. This means that for delayed or scheduled jobs to be executed, the worker needs to be running.

A basic "up-and-running" resque-scheduler.php file is included that sets up a running worker environment is included in the root directory. It accepts many of the same environment variables as php-resque:

  • REDIS_BACKEND - Redis server to connect to
  • LOGGING - Enable logging to STDOUT
  • VERBOSE - Enable verbose logging
  • VVERBOSE - Enable very verbose logging
  • INTERVAL - Sleep for this long before checking scheduled/delayed queues
  • APP_INCLUDE - Include this file when starting (to launch your app)
  • PIDFILE - Write the PID of the worker out to this file

The resque-scheduler worker requires resque to function. The demo resque-scheduler.php worker allows you to supply a RESQUE_PHP environment variable with the path to Resque.php. If not supplied and resque is not already loaded, resque-scheduler will attempt to load it from your include path (require_once 'Resque/Resque.php';')

It's easy to start the resque-scheduler worker using resque-scheduler.php: $ RESQUE_PHP=../resque/lib/Resque/Resque.php php resque-scheduler.php

Event/Hook System

php-resque-scheduler uses the same event system used by php-resque and exposes the following events.

afterSchedule

Called after a job has been added to the schedule. Arguments passed are the timestamp, queue of the job, the class name of the job, and the job's arguments.

beforeDelayedEnqueue

Called immediately after a job has been pulled off the delayed queue and right before the job is added to the queue in resque. Arguments passed are the queue of the job, the class name of the job, and the job's arguments.

Contributors

  • chrisboulton
  • Wan Qi Chen (Kamisama)

kamisama/php-resque-ex-scheduler 适用场景与选型建议

kamisama/php-resque-ex-scheduler 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 625k 次下载、GitHub Stars 达 27, 最近一次更新时间为 2026 年 01 月 04 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「redis」 「queue」 「php」 「cron」 「schedule」 「background」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 kamisama/php-resque-ex-scheduler 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 kamisama/php-resque-ex-scheduler 我们能提供哪些服务?
定制开发 / 二次开发

基于 kamisama/php-resque-ex-scheduler 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 625k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 27
  • 点击次数: 28
  • 依赖项目数: 7
  • 推荐数: 1

GitHub 信息

  • Stars: 27
  • Watchers: 7
  • Forks: 23
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04