yf_queue_driver_redis class| File | plugins/queue/classes/queue/yf_queue_driver_redis.class.php |
|---|---|
| Use | _class('queue_driver_redis', 'classes/queue/') |
| Extends | yf_queue_driver |
A site sets them in its config with $PROJECT_CONF['queue_driver_redis']['NAME'] = ...;
| Property | Default | Description |
|---|---|---|
$_connection |
null |
public function add($queue, $what)
public function add($queue, $what)
{
! $this->_connection && $this->connect();
return $this->_connection->lpush($queue, $what);
}
public function all($queue)
public function all($queue)
{
! $this->_connection && $this->connect();
return $this->_connection->lrange($queue, 0, -1);
}
public function conf($params = [])
public function conf($params = [])
{
! $this->_connection && $this->connect();
$this->_connection->conf($params);
return $this;
}
public function connect($options = [])
public function connect($options = [])
{
if ( ! $this->_connection) {
if ( ! $options) {
$options = [
'REDIS_HOST' => $this->_get_conf('REDIS_QUEUE_HOST'),
'REDIS_PORT' => $this->_get_conf('REDIS_QUEUE_PORT'),
'REDIS_PREFIX' => $this->_get_conf('REDIS_QUEUE_PREFIX'),
];
}
$this->_connection = redis()->factory($options);
$this->_connection->connect();
}
if ( ! $this->_connection->is_connection()) {
$this->reconnect();
}
return $this->_connection;
}
public function del($queue)
public function del($queue)
{
! $this->_connection && $this->connect();
return $this->_connection->lrem($queue, 1);
}
public function get($queue)
public function get($queue)
{
! $this->_connection && $this->connect();
return $this->_connection->rpop($queue);
}
public function is_ready()
public function is_ready()
{
! $this->_connection && $this->connect();
return (bool) $this->_connection;
}
public function reconnect()
public function reconnect()
{
$this->_connection && $this->_connection->reconnect();
}
_ hooks and helpers; not routable as page actionspublic function _get_conf($name, $default = null, array $params = [])
$params array public function _get_conf($name, $default = null, array $params = [])
{
if (isset($params[$name])) {
return $params[$name];
}
$from_env = getenv($name);
if ($from_env !== false) {
return $from_env;
}
global $CONF;
if (isset($CONF[$name])) {
$from_conf = $CONF[$name];
return $from_conf;
}
if (defined($name) && ($val = constant($name)) != $name) {
return $val;
}
return $default;
}
from yf_queue_driver: __call()