PHP Class UrbanIndo\Yii2\Queue\Queues\DbQueue

The schema of the table should follow: CREATE TABLE queue ( id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT, status TINYINT NOT NULL DEFAULT 0, timestamp DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, data BLOB ); The queue works under the asumption that the id fields is AUTO_INCREMENT and the timestamp will be set using current timestamp. For other implementation, override the fetchLatestRow method and postJob method.
Since: 2016.01.16
Author: Petra Barus ([email protected])
Inheritance: extends UrbanIndo\Yii2\Queue\Queue
Afficher le fichier Open project: urbanindo/yii2-queue

Méthodes publiques

Свойство Type Description
$db string | yii\db\Connection This will use default db component from Yii application.
$hardDelete boolean Whether to do hard delete of the deleted job, instead of just flagging the status.
$tableName string The table should be pre-created as follows for MySQL: php CREATE TABLE queue ( id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT, status TINYINT NOT NULL DEFAULT 0, timestamp DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, data LONGBLOB );

Méthodes publiques

Méthode Description
deleteJob ( UrbanIndo\Yii2\Queue\Job $job ) : boolean Delete the job. Override this for the queue implementation.
getSize ( ) : integer Returns the number of queue size.
init ( ) : void
purge ( ) : boolean Purge the whole queue.
releaseJob ( UrbanIndo\Yii2\Queue\Job $job ) : boolean Restore job from active to ready.

Méthodes protégées

Méthode Description
fetchJob ( ) : UrbanIndo\Yii2\Queue\Job | boolean Return next job from the queue.
fetchLatestRow ( ) : array Fetch latest ready job from the table.
flagRunningRow ( array $row ) : boolean Flag a row as running. This will update the row ID and status if ready.
postJob ( UrbanIndo\Yii2\Queue\Job $job ) : boolean Post new job to the queue. This contains implementation for database.

Method Details

deleteJob() public méthode

Delete the job. Override this for the queue implementation.
public deleteJob ( UrbanIndo\Yii2\Queue\Job $job ) : boolean
$job UrbanIndo\Yii2\Queue\Job The job to delete.
Résultat boolean whether the operation succeed.

fetchJob() protected méthode

Return next job from the queue.
protected fetchJob ( ) : UrbanIndo\Yii2\Queue\Job | boolean
Résultat UrbanIndo\Yii2\Queue\Job | boolean the job or false if not found.

fetchLatestRow() protected méthode

Due to the use of AUTO_INCREMENT ID, this will fetch the job with the largest ID.
protected fetchLatestRow ( ) : array
Résultat array

flagRunningRow() protected méthode

Flag a row as running. This will update the row ID and status if ready.
protected flagRunningRow ( array $row ) : boolean
$row array The row to update.
Résultat boolean Whether successful or not.

getSize() public méthode

Returns the number of queue size.
public getSize ( ) : integer
Résultat integer

init() public méthode

public init ( ) : void
Résultat void

postJob() protected méthode

Post new job to the queue. This contains implementation for database.
protected postJob ( UrbanIndo\Yii2\Queue\Job $job ) : boolean
$job UrbanIndo\Yii2\Queue\Job The job to post.
Résultat boolean whether operation succeed.

purge() public méthode

Purge the whole queue.
public purge ( ) : boolean
Résultat boolean

releaseJob() public méthode

Restore job from active to ready.
public releaseJob ( UrbanIndo\Yii2\Queue\Job $job ) : boolean
$job UrbanIndo\Yii2\Queue\Job The job to restore.
Résultat boolean whether the operation succeed.

Property Details

$db public_oe property

This will use default db component from Yii application.
public string|Connection,yii\db $db
Résultat string | yii\db\Connection

$hardDelete public_oe property

Whether to do hard delete of the deleted job, instead of just flagging the status.
public bool $hardDelete
Résultat boolean

$tableName public_oe property

The table should be pre-created as follows for MySQL: php CREATE TABLE queue ( id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT, status TINYINT NOT NULL DEFAULT 0, timestamp DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, data LONGBLOB );
public string $tableName
Résultat string