Download the PHP package rpq/client without Composer
On this page you can find all versions of the php package rpq/client. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Package client
Short Description Redis Priority Queue Client implementation in pure PHP
License BSD-3-Clause
Informations about the package client
Redis Priority Queue Client
RPQ-Client is a priority task queue implementation in Redis written in pure PHP. This repository contains the Client codebase which can be used to schedule jobs from applications. Additionally, this codebase is used by the RPQ Server implementation to work with and process jobs.
Note that this codebase is constantly evolving. Until a tagged release is made, the API may change at any time.
Installation
RPQ-Client can be added to your application via Composer.
Note that RPQ-Client requires PHPRedis.
Usage
The RPQ Client comes with several options to instantiate the queue. To begin using the RPQ client, connect to your Redis instance, then pass that Redis instance to the RPQ\Client
object.
Adding Jobs
Jobs can be scheduled for immediate execution simply by pushing a Fully Qualified Class Name to the queue.
Job arguments can be a complex array. As long as the details are JSON serializable, it can be passed to RPQ. Jobs have a default priority of 1
. Jobs with a higher priority will execute before jobs with a lower priority. The priority may range from PHP_INT_MIN
to PHP_INT_MAX
.
Retries may either be defined as a boolean
or as an integer
. If retry
is set to true
, the job will be continuously rescheduled until it passes. If retry
is set to false
, no attempt will be made to retry the job. If retry
is set to an integer, exactly n
retries will be attempted, after which the job will be failed.
After pushing a job onto the stack, the push
method will return a Job
instance which can be used to determine the status and other information of the job.
Note that complex Objects should NOT be passed as an arguement. If you need to access a complex object, you should re-instantiate it within your job class.
Future Scheduling
Jobs may be scheduled in the future by specifying the at
parameter, which represents a unix timestamp of the time you wish for the job to execute at.
Note that the
at
parameter declares the earliest a job will execute, and does not guarantee that a job will execute at that time. The scheduler will prioritize future jobs when possible, but other jobs may have priority over it depending upon the priority. If you require exact timining, the job should have a priority ofPHP_MAX_INT
, and you should ensure that your job queue has sufficient workers to prevent the job execution from being delayed.
Queue Statistics
Details about the queue can be retrieved as follows:
The stats command will return an array containing the number of elements in the queue, and details about the passed, failed, canceled, and retried jobs for the given day.
To retrieve stats for a different day, call get()
with a Y-m-d
formatted date.