PHP code example of ldkafka / yii2-queue-redis-ng

1. Go to this page and download the library: Download ldkafka/yii2-queue-redis-ng library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ldkafka / yii2-queue-redis-ng example snippets


'queue' => [
    'class' => \ldkafka\queue\redis\Queue::class, // was \yii\queue\redis\Queue::class
    // everything else stays as it is
],

'components' => [
    'queue' => [
        'class' => \ldkafka\queue\redis\Queue::class, // was \yii\queue\redis\Queue::class
        'redis' => 'redis',
        'channel' => 'queue',
    ],
],

Yii::$app->queue->push($job);                               // default priority, 1024
Yii::$app->queue->priority(10)->push($job);                 // more urgent: lower runs first
Yii::$app->queue->priority(5000)->push($job);               // less urgent
Yii::$app->queue->delay(3600)->priority(10)->push($job);    // in an hour, and urgent then

'aging' => 1, // a job 100 points more urgent overtakes only jobs that joined less than 100 s before it

Yii::$app->queue->flatten(); // returns the number of jobs moved, most urgent first