scones/resque

resque (for php) is a Redis-backed library for creating background jobs, placing them on multiple queues, and processing them later. compatible to the original http://resque.github.io/

1.0.10 2019-05-28 11:59 UTC

This package is auto-updated.

Last update: 2024-11-29 00:35:36 UTC


README

Build Status Scrutinizer Code Quality Code Coverage

Resque

PHP implementation of the resque mechanism.

This is a completely new implementation featuring things as

  • no static methods
  • minimalistic dependencies (only core features for the asynchronous task processing)
  • good coding standards
  • psr events as tasks, thus the behavior can be modified
  • strict typing

Install

In most cases it should suffice to just install it via composer.

composer require scones/resque "*@stable"

How does it work?

The resque task processing is a decentral queueing system. (read: no master server or similar) There are two parts to the processing, pushing jobs and working job. Those should not run in the same application or at least process to gain the most benefit from it.

pushing jobs

The first step to process a job is to put it on the queue. Assuming you have the resque class already instantiated, you'd be just calling $resque->enqueue('SomeClass', ['some' => 'data'], 'some_queue')

This method puts the task on the queue and returns. It will not process it, as it is not its job. The data is stored (in a very precise format) in a redis database.

working jobs

The second step to process a job is the worker. The worker is an process running anywhere with access to the same redis database.

The worker waits new entries in the configured queues and fetches one, as soon as it's available. When this happens, it builds the corresponding class (from the supplied container/servicelocator, see examples) and invokes perform with the array provided in enqueue as arguments.

Examples

Find runnable usage examples under https://github.com/scones/resque-examples