PHP 클래스 Resque, php-resque

저자: Chris Boulton ([email protected])
파일 보기 프로젝트 열기: chrisboulton/php-resque 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$redis Instance of Resque_Redis that talks to redis.

보호된 프로퍼티들

프로퍼티 타입 설명
$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