PHP Класс Resque, php-resque

Автор: Chris Boulton ([email protected])
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$redis Instance of Resque_Redis that talks to redis.

Защищенные свойства (Protected)

Свойство Тип Описание
$redisDatabase ID of Redis database to select.
$redisServer Host/port conbination separated by a colon, or a nested array of server swith host/port pairs

Открытые методы

Метод Описание
blpop ( array $queues, integer $timeout ) : null | array Pop an item off the end of the specified queues, using blocking list pop, decode it and return it.
dequeue ( string $queue, array $items = [] ) : integer Remove items of the specified queue
enqueue ( string $queue, string $class, array $args = null, boolean $trackStatus = false ) : string | boolean Create a new job and save it to the specified queue.
fork ( ) : integer fork() helper method for php-resque that handles issues PHP socket and phpredis have with passing around sockets between child/parent processes.
generateJobId ( ) * Generate an identifier to attach to a job for status tracking.
pop ( string $queue ) : array Pop an item off the end of the specified queue, decode it and return it.
push ( string $queue, array $item ) Push a job to the end of a specific queue. If the queue does not exist, then create it as well.
queues ( ) : array Get an array of all known queues.
redis ( ) : Resque_Redis Return an instance of the Resque_Redis class instantiated for Resque.
removeQueue ( string $queue ) : integer Remove specified queue
reserve ( string $queue ) : Resque_Job Reserve and return the next available job in the specified queue.
setBackend ( mixed $server, integer $database ) Given a host/port combination separated by a colon, set it as the redis server that Resque will talk to.
size ( string $queue ) : integer Return the size (number of pending jobs) of the specified queue.

Приватные методы

Метод Описание
matchItem ( $string, $items ) : (bool) matching item item can be ['class'] or ['class' => 'id'] or ['class' => {:foo => 1, :bar => 2}]
removeItems ( string $queue, array $items = [] ) : integer Remove Items from the queue Safely moving each item to a temporary queue before processing it If the Job matches, counts otherwise puts it in a requeue_queue which at the end eventually be copied back into the original queue
removeList ( $queue ) : integer Remove List

Описание методов

blpop() публичный статический Метод

Pop an item off the end of the specified queues, using blocking list pop, decode it and return it.
public static blpop ( array $queues, integer $timeout ) : null | array
$queues array
$timeout integer
Результат null | array Decoded item from the queue.

dequeue() публичный статический Метод

Remove items of the specified queue
public static dequeue ( string $queue, array $items = [] ) : integer
$queue string The name of the queue to fetch an item from.
$items array
Результат integer number of deleted items

enqueue() публичный статический Метод

Create a new job and save it to the specified queue.
public static enqueue ( string $queue, string $class, array $args = null, boolean $trackStatus = false ) : string | boolean
$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.
Результат string | boolean Job ID when the job was created, false if creation was cancelled due to beforeEnqueue

fork() публичный статический Метод

Will close connection to Redis before forking.
public static fork ( ) : integer
Результат integer Return vars as per pcntl_fork(). False if pcntl_fork is unavailable

generateJobId() публичный статический Метод

* Generate an identifier to attach to a job for status tracking.
public static generateJobId ( )

pop() публичный статический Метод

Pop an item off the end of the specified queue, decode it and return it.
public static pop ( string $queue ) : array
$queue string The name of the queue to fetch an item from.
Результат array Decoded item from the queue.

push() публичный статический Метод

Push a job to the end of a specific queue. If the queue does not exist, then create it as well.
public static push ( string $queue, array $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() публичный статический Метод

Get an array of all known queues.
public static queues ( ) : array
Результат array Array of queues.

redis() публичный статический Метод

Return an instance of the Resque_Redis class instantiated for Resque.
public static redis ( ) : Resque_Redis
Результат Resque_Redis Instance of Resque_Redis.

removeQueue() публичный статический Метод

Remove specified queue
public static removeQueue ( string $queue ) : integer
$queue string The name of the queue to remove.
Результат integer Number of deleted items

reserve() публичный статический Метод

Reserve and return the next available job in the specified queue.
public static reserve ( string $queue ) : Resque_Job
$queue string Queue to fetch next available job from.
Результат Resque_Job Instance of Resque_Job to be processed, false if none or error.

setBackend() публичный статический Метод

Given a host/port combination separated by a colon, set it as the redis server that Resque will talk to.
public static setBackend ( mixed $server, integer $database )
$server mixed Host/port combination separated by a colon, DSN-formatted URI, or a callable that receives the configured database ID and returns a Resque_Redis instance, or a nested array of servers with host/port pairs.
$database integer

size() публичный статический Метод

Return the size (number of pending jobs) of the specified queue.
public static size ( string $queue ) : integer
$queue string name of the queue to be checked for pending jobs
Результат integer The size of the queue.

Описание свойств

$redis публичное статическое свойство

Instance of Resque_Redis that talks to redis.
public static $redis

$redisDatabase защищенное статическое свойство

ID of Redis database to select.
protected static $redisDatabase

$redisServer защищенное статическое свойство

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