Class Resque

InheritanceResque

Base Resque class.

Public Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
$redis Resque_Redis Instance of Resque_Redis that talks to redis. Resque

Protected Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
$pid int PID of current process. Resque
$redisDatabase int ID of Redis database to select. Resque
$redisServer mixed Host/port conbination separated by a colon, or a nested array of server swith host/port pairs Resque

Public Methods

Hide inherited methods

MethodDescriptionDefined By
enqueue() Create a new job and save it to the specified queue. Resque
pop() Pop an item off the end of the specified queue, decode it and return it. Resque
push() Push a job to the end of a specific queue. If the queue does not exist, then create it as well. Resque
queues() Get an array of all known queues. Resque
redis() Return an instance of the Resque_Redis class instantiated for Resque. Resque
reserve() Reserve and return the next available job in the specified queue. Resque
setBackend() Given a host/port combination separated by a colon, set it as the redis server that Resque will talk to. Resque
size() Return the size (number of pending jobs) of the specified queue. Resque

Constants

Hide inherited constants

ConstantValueDescriptionDefined By
VERSION '1.2' Resque

Property Details

$pid protected static property

PID of current process. Used to detect changes when forking and implement "thread" safety to avoid race conditions.

protected static int $pid null
$redis public static property

Instance of Resque_Redis that talks to redis.

public static Resque_Redis $redis null
$redisDatabase protected static property

ID of Redis database to select.

protected static int $redisDatabase 0
$redisServer protected static property

Host/port conbination separated by a colon, or a nested array of server swith host/port pairs

protected static mixed $redisServer null

Method Details

enqueue() public static method

Create a new job and save it to the specified queue.

public static string enqueue ( $queue, $class, $args null, $trackStatus false )
$queue string

The name of the queue to place the job in.

$class string

The name of the class that contains the code to execute the job.

$args array

Any optional arguments that should be passed when the job is executed.

$trackStatus boolean

Set to true to be able to monitor the status of a job.

pop() public static method

Pop an item off the end of the specified queue, decode it and return it.

public static array pop ( $queue )
$queue string

The name of the queue to fetch an item from.

return array

Decoded item from the queue.

push() public static method

Push a job to the end of a specific queue. If the queue does not exist, then create it as well.

public static void push ( $queue, $item )
$queue string

The name of the queue to add the job to.

$item array

Job description as an array to be JSON encoded.

queues() public static method

Get an array of all known queues.

public static array queues ( )
return array

Array of queues.

redis() public static method

Return an instance of the Resque_Redis class instantiated for Resque.

public static Resque_Redis redis ( )
return Resque_Redis

Instance of Resque_Redis.

reserve() public static method

Reserve and return the next available job in the specified queue.

public static Resque_Job reserve ( $queue )
$queue string

Queue to fetch next available job from.

return Resque_Job

Instance of Resque_Job to be processed, false if none or error.

setBackend() public static method

Given a host/port combination separated by a colon, set it as the redis server that Resque will talk to.

public static void setBackend ( $server, $database 0 )
$server mixed

Host/port combination separated by a colon, or

                 a nested array of servers with host/port pairs.
$database int
size() public static method

Return the size (number of pending jobs) of the specified queue.

public static int size ( $queue )
$queue

Name of the queue to be checked for pending jobs

return int

The size of the queue.