\think\queueWorker

Summary

Methods
Properties
Constants
daemon()
pop()
process()
memoryExceeded()
stop()
sleep()
No public properties found
No constants found
runNextJobForDaemon()
getNextJob()
logFailedJob()
getTimestampOfLastQueueRestart()
queueShouldRestart()
getExceptionHandler()
No protected properties found
N/A
No private methods found
No private properties found
N/A

Methods

daemon()

daemon(string  $queue = null, integer  $delay, integer  $memory = 128, integer  $sleep = 3, integer  $maxTries) : array

启动一个守护进程执行任务.

Parameters

string $queue
integer $delay
integer $memory
integer $sleep
integer $maxTries

Returns

array

pop()

pop(string  $queue = null, integer  $delay, integer  $sleep = 3, integer  $maxTries) : array

执行下个任务

Parameters

string $queue
integer $delay
integer $sleep
integer $maxTries

Returns

array

process()

process(\think\queue\Job  $job, integer  $maxTries, integer  $delay) : array

Process a given job from the queue.

Parameters

\think\queue\Job $job
integer $maxTries
integer $delay

Throws

\Exception

Returns

array

memoryExceeded()

memoryExceeded(integer  $memoryLimit) : boolean

检查内存是否超出

Parameters

integer $memoryLimit

Returns

boolean

stop()

stop() : void

停止执行任务的守护进程.

sleep()

sleep(integer  $seconds) : void

Sleep the script for a given number of seconds.

Parameters

integer $seconds

runNextJobForDaemon()

runNextJobForDaemon(string  $queue, integer  $delay, integer  $sleep, integer  $maxTries) : void

以守护进程的方式执行下个任务.

Parameters

string $queue
integer $delay
integer $sleep
integer $maxTries

getNextJob()

getNextJob(string  $queue) 

获取下个任务

Parameters

string $queue

logFailedJob()

logFailedJob(\Think\Queue\Job  $job) : array

Log a failed job into storage.

Parameters

\Think\Queue\Job $job

Returns

array

getTimestampOfLastQueueRestart()

getTimestampOfLastQueueRestart() : integer|null

获取上次重启守护进程的时间

Returns

integer|null

queueShouldRestart()

queueShouldRestart(integer|null  $lastRestart) : boolean

检查是否要重启守护进程

Parameters

integer|null $lastRestart

Returns

boolean

getExceptionHandler()

getExceptionHandler() : \think\exception\Handle

获取异常处理实例

Returns

\think\exception\Handle