Class zhuravljov\yii\queue\redis\Driver
| Inheritance | zhuravljov\ |
|---|---|
| Implements | yii\ |
| 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\ |
|
| $queue | zhuravljov\ |
zhuravljov\ |
|
| $redis | \ |
zhuravljov\ |
Public Methods
| Method | Description | Defined By |
|---|---|---|
| __construct() | zhuravljov\ |
|
| bootstrap() | zhuravljov\ |
|
| init() | zhuravljov\ |
|
| pop() | Pops message and job from the storage. | zhuravljov\ |
| purge() | Purges the storage. | zhuravljov\ |
| push() | Pushes job to the storage. | zhuravljov\ |
| release() | Releases the message. | zhuravljov\ |
Protected Methods
| Method | Description | Defined By |
|---|---|---|
| getKey() | zhuravljov\ |
|
| getQueue() | zhuravljov\ |
Property Details
Method Details
Defined in:
zhuravljov\
| public __construct ( zhuravljov\ | ||
| $queue | zhuravljov\ |
|
| $config | mixed | |
public function __construct(Queue $queue, $config = [])
{
$this->_queue = $queue;
parent::__construct($config);
}
| public bootstrap ( mixed $app ) | ||
| $app | mixed | |
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\
| protected zhuravljov\ |
protected function getQueue()
{
return $this->_queue;
}
| public init ( ) |
public function init()
{
parent::init();
$this->redis = Instance::ensure($this->redis, Connection::class);
}
Pops message and job from the storage.
| public boolean pop ( mixed &$message, mixed &$job ) | ||
| $message | mixed | |
| $job | mixed | |
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 mixed purge ( ) |
public function purge()
{
$this->redis->executeCommand('DEL', [$this->getKey()]);
}
Pushes job to the storage.
| public mixed push ( mixed $job ) | ||
| $job | mixed | |
| return | mixed |
$message |
|---|---|---|
public function push($job)
{
$message = serialize($job);
$this->redis->executeCommand('RPUSH', [$this->getKey(), $message]);
return $message;
}