PHP Class Resque\Queue

Author: Michael Haynes ([email protected])
Show file Open project: mjphaynes/php-resque Class Usage Examples

Protected Properties

Property Type Description
$default The name of the default queue
$redis The Redis instance

Public Methods

Method Description
__construct ( string $default = null ) Create a new queue instance
job ( string $id ) : Job Get a job by id
later ( integer $delay, string $job, array $data = [], string $queue = null ) : Job Queue a job for later retrieval. Jobs are unique per queue and are deleted upon retrieval. If a given job (payload) already exists, it is updated with the new delay.
pop ( array $queues, integer $timeout = 10, boolean $blocking = true ) : Job | false Pop the next job off of the queue.
push ( string $job, array $data = null, string $queue = null ) : Job Push a new job onto the queue
redisKey ( Queue | null $queue = null, string | null $suffix = null ) : string Get the Queue key
size ( string $queue ) : integer Return the size (number of pending jobs) of the specified queue.
sizeDelayed ( string $queue ) : integer Return the size (number of delayed jobs) of the specified queue.

Protected Methods

Method Description
getQueue ( string | null $queue ) : string Get the queue or return the default.

Method Details

__construct() public method

Create a new queue instance
public __construct ( string $default = null )
$default string Name of default queue to add job to

getQueue() protected method

Get the queue or return the default.
protected getQueue ( string | null $queue ) : string
$queue string | null Name of queue
return string

job() public method

Get a job by id
public job ( string $id ) : Job
$id string Job id
return Job job instance

later() public method

Queue a job for later retrieval. Jobs are unique per queue and are deleted upon retrieval. If a given job (payload) already exists, it is updated with the new delay.
public later ( integer $delay, string $job, array $data = [], string $queue = null ) : Job
$delay integer This can be number of seconds or unix timestamp
$job string The job class
$data array The job data
$queue string The queue to add the job to
return Job job instance

pop() public method

Pop the next job off of the queue.
public pop ( array $queues, integer $timeout = 10, boolean $blocking = true ) : Job | false
$queues array Queues to watch for new jobs
$timeout integer Timeout if blocking
$blocking boolean Should Redis use blocking
return Job | false

push() public method

Push a new job onto the queue
public push ( string $job, array $data = null, string $queue = null ) : Job
$job string The job class
$data array The job data
$queue string The queue to add the job to
return Job job instance

redisKey() public static method

Get the Queue key
public static redisKey ( Queue | null $queue = null, string | null $suffix = null ) : string
$queue Queue | null the worker to get the key for
$suffix string | null to be appended to key
return string

size() public method

Return the size (number of pending jobs) of the specified queue.
public size ( string $queue ) : integer
$queue string name of the queue to be checked for pending jobs
return integer The size of the queue.

sizeDelayed() public method

Return the size (number of delayed jobs) of the specified queue.
public sizeDelayed ( string $queue ) : integer
$queue string name of the queue to be checked for delayed jobs
return integer The size of the delayed queue.

Property Details

$default protected property

The name of the default queue
protected $default

$redis protected property

The Redis instance
protected $redis