Class zhuravljov\yii\queue\redis\Driver
Inheritance | zhuravljov\yii\queue\redis\Driver » zhuravljov\yii\queue\Driver » yii\base\Object |
---|---|
Implements | yii\base\BootstrapInterface |
Source Code | https://github.com/yiisoft/yii2-queue/blob/master/src/redis/Driver.php |
Redis Driver
Public Properties
Property | Type | Description | Defined By |
---|---|---|---|
$prefix | string | zhuravljov\yii\queue\redis\Driver | |
$queue | zhuravljov\yii\queue\Queue | zhuravljov\yii\queue\Driver | |
$redis | \yii\redis\Connection|array|string | zhuravljov\yii\queue\redis\Driver |
Public Methods
Method | Description | Defined By |
---|---|---|
__construct() | zhuravljov\yii\queue\Driver | |
bootstrap() | zhuravljov\yii\queue\redis\Driver | |
init() | zhuravljov\yii\queue\redis\Driver | |
pop() | Pops message and job from the storage. | zhuravljov\yii\queue\redis\Driver |
purge() | Purges the storage. | zhuravljov\yii\queue\redis\Driver |
push() | Pushes job to the storage. | zhuravljov\yii\queue\redis\Driver |
release() | Releases the message. | zhuravljov\yii\queue\redis\Driver |
Protected Methods
Method | Description | Defined By |
---|---|---|
getKey() | zhuravljov\yii\queue\redis\Driver | |
getQueue() | zhuravljov\yii\queue\Driver |
Property Details
Method Details
Defined in: zhuravljov\yii\queue\Driver::__construct()
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);
}
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,
];
}
}
protected string getKey ( ) |
protected function getKey()
{
return $this->prefix . $this->queue->id;
}
Defined in: zhuravljov\yii\queue\Driver::getQueue()
protected zhuravljov\yii\queue\Queue getQueue ( ) |
protected function getQueue()
{
return $this->_queue;
}
public void init ( ) |
public function init()
{
parent::init();
$this->redis = Instance::ensure($this->redis, Connection::class);
}
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;
}
}
Purges the storage.
public void purge ( ) |
public function purge()
{
$this->redis->executeCommand('DEL', [$this->getKey()]);
}
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;
}
Releases the message.
public void release ( $message ) | ||
$message |
public function release($message)
{
}