Class zhuravljov\yii\queue\redis\Driver

Inheritancezhuravljov\yii\queue\redis\Driver » zhuravljov\yii\queue\Driver » yii\base\Object
Implementsyii\base\BootstrapInterface
Source Code https://github.com/yiisoft/yii2-queue/blob/master/src/redis/Driver.php

Redis Driver

Property Details

Hide inherited properties

$prefix public property
public string $prefix ''
$redis public property
public \yii\redis\Connection|array|string $redis 'redis'

Method Details

Hide inherited methods

__construct() public method
public void __construct ( zhuravljov\yii\queue\Queue $queue, $config = [] )
$queue zhuravljov\yii\queue\Queue
$config

                public function __construct(Queue $queue, $config = [])
{
    $this->_queue = $queue;
    parent::__construct($config);
}

            
bootstrap() public method

public void bootstrap ( $app )
$app

                public function bootstrap($app)
{
    if ($app instanceof \yii\console\Application) {
        $app->controllerMap[$this->queue->id] = [
            'class' => Command::class,
            'queue' => $this->queue,
        ];
    }
}

            
getKey() protected method

protected string getKey ( )

                protected function getKey()
{
    return $this->prefix . $this->queue->id;
}

            
getQueue() protected method
protected zhuravljov\yii\queue\Queue getQueue ( )

                protected function getQueue()
{
    return $this->_queue;
}

            
init() public method

public void init ( )

                public function init()
{
    parent::init();
    $this->redis = Instance::ensure($this->redis, Connection::class);
}

            
pop() public method

Pops message and job from the storage.

public boolean pop ( &$message, &$job )
$message mixed
$job zhuravljov\yii\queue\Job

                public function pop(&$message, &$job)
{
    $message = $this->redis->executeCommand('LPOP', [$this->getKey()]);
    if ($message !== null) {
        $job = unserialize($message);
        return true;
    } else {
        return false;
    }
}

            
purge() public method

Purges the storage.

public void purge ( )

                public function purge()
{
    $this->redis->executeCommand('DEL', [$this->getKey()]);
}

            
push() public method

Pushes job to the storage.

public mixed push ( $job )
$job zhuravljov\yii\queue\Job
return mixed

$message

                public function push($job)
{
    $message = serialize($job);
    $this->redis->executeCommand('RPUSH', [$this->getKey(), $message]);
    return $message;
}

            
release() public method

Releases the message.

public void release ( $message )
$message

                public function release($message)
{
}