Class Resque
Inheritance | Resque |
---|
Base Resque class.
Public Properties
Property | Type | Description | Defined By |
---|---|---|---|
$redis | Resque_Redis | Instance of Resque_Redis that talks to redis. | Resque |
Protected Properties
Property | Type | Description | Defined 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
Method | Description | Defined 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 |
Property Details
PID of current process. Used to detect changes when forking and implement "thread" safety to avoid race conditions.
Instance of Resque_Redis that talks to redis.
ID of Redis database to select.
Host/port conbination separated by a colon, or a nested array of server swith host/port pairs
Method Details
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 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 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. |
Get an array of all known queues.
public static array queues ( ) | ||
return | array | Array of queues. |
---|
Return an instance of the Resque_Redis class instantiated for Resque.
public static Resque_Redis redis ( ) | ||
return | Resque_Redis | Instance of Resque_Redis. |
---|
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. |
---|
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
|
$database | int |
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. |
---|