yii\queue\db\Queue - Yii2 类参考手册

Class yii\queue\db\Queue

Inheritanceyii\queue\db\Queue » yii\queue\cli\Queue » yii\queue\Queue » yii\base\Component » yii\base\BaseObject
Implementsyii\base\BootstrapInterface, yii\base\Configurable

Db Queue

Public Methods

隐藏继承的方法 Hide inherited methods

方法 Method简介 Description定义在 Defined By
__call() Calls the named method which is not a class method. yii\base\Component
__clone() This method is called after the object is created by cloning an existing one. yii\base\Component
__construct() Constructor. yii\base\BaseObject
__get() Returns the value of a component property. yii\base\Component
__isset() Checks if a property is set, i.e. defined and not null. yii\base\Component
__set() Sets the value of a component property. yii\base\Component
__unset() Sets a component property to be null. yii\base\Component
attachBehavior() Attaches a behavior to this component. yii\base\Component
attachBehaviors() Attaches a list of behaviors to the component. yii\base\Component
behaviors() Returns a list of behaviors that this component should behave as. yii\base\Component
bootstrap() Bootstrap method to be called during application bootstrap stage. yii\queue\cli\Queue
canGetProperty() Returns a value indicating whether a property can be read. yii\base\Component
canSetProperty() Returns a value indicating whether a property can be set. yii\base\Component
className() Returns the fully qualified name of this class. yii\base\BaseObject
clear() Clears the queue yii\queue\db\Queue
delay() Sets delay for later execute yii\queue\Queue
detachBehavior() Detaches a behavior from the component. yii\base\Component
detachBehaviors() Detaches all behaviors from the component. yii\base\Component
ensureBehaviors() Makes sure that the behaviors declared in behaviors() are attached to this component. yii\base\Component
execute() yii\queue\cli\Queue
getBehavior() Returns the named behavior object. yii\base\Component
getBehaviors() Returns all behaviors attached to this component. yii\base\Component
getWorkerPid() Gets process ID of a worker. yii\queue\cli\Queue
handleError() yii\queue\Queue
hasEventHandlers() Returns a value indicating whether there is any handler attached to the named event. yii\base\Component
hasMethod() Returns a value indicating whether a method is defined. yii\base\Component
hasProperty() Returns a value indicating whether a property is defined for this component. yii\base\Component
init() Initializes the object. yii\queue\db\Queue
isDone() yii\queue\Queue
isReserved() yii\queue\Queue
isWaiting() yii\queue\Queue
off() Detaches an existing event handler from this component. yii\base\Component
on() Attaches an event handler to an event. yii\base\Component
priority() Sets job priority yii\queue\Queue
push() Pushes job into queue yii\queue\Queue
remove() Removes a job by ID yii\queue\db\Queue
run() Listens queue and runs each job. yii\queue\db\Queue
status() yii\queue\db\Queue
trigger() Triggers an event. yii\base\Component
ttr() Sets TTR for job execute yii\queue\Queue

Protected Methods

隐藏继承的方法 Hide inherited methods

方法 Method简介 Description定义在 Defined By
getCommandId() yii\queue\cli\Queue
handleMessage() yii\queue\cli\Queue
pushMessage() yii\queue\db\Queue
release() yii\queue\db\Queue
reserve() Takes one message from waiting list and reserves it for handling. yii\queue\db\Queue
runWorker() Runs worker. yii\queue\cli\Queue

常量 Constants

隐藏继承的常量 Hide inherited constants

常量 Constant值 Value简介 Description定义在 Defined By
STATUS_DONE 3 yii\queue\Queue
STATUS_RESERVED 2 yii\queue\Queue
STATUS_WAITING 1 yii\queue\Queue

属性详情 Property Details

$channel public property
public string $channel 'queue'
$commandClass public property

Command class name

public string $commandClass = \yii\queue\db\Command::class
$db public property
$deleteReleased public property

Ability to delete released messages from table

public boolean $deleteReleased true
$mutex public property
$mutexTimeout public property

Timeout

$tableName public property

Table name

public string $tableName '{{%queue}}'

方法详情 Method Details

clear() public method (available since version 2.0.1)

Clears the queue

public void clear ( )
init() public method

Initializes the object.

This method is invoked at the end of the constructor after the object is initialized with the given configuration.

public void init ( )
pushMessage() protected method

protected string pushMessage ( $message, $ttr, $delay, $priority )
$message string
$ttr integer

Time to reserve in seconds

$delay integer
$priority mixed
return string

Id of a job message

release() protected method

protected void release ( $payload )
$payload array
remove() public method (available since version 2.0.1)

Removes a job by ID

public boolean remove ( $id )
$id integer

Of a job

reserve() protected method

Takes one message from waiting list and reserves it for handling.

protected array|false reserve ( )
return array|false

Payload

throws yii\base\Exception

in case it hasn't waited the lock

run() public method (available since version 2.0.2)

Listens queue and runs each job.

public null|integer run ( $repeat, $delay 0 )
$repeat boolean

Whether to continue listening when queue is empty.

$delay integer

Number of seconds to sleep before next iteration.

return null|integer

Exit code.

status() public method

public integer status ( $id )
$id string

Of a job message

return integer

Status code