yf_pubsub_driver_redis class| File | plugins/pubsub/classes/pubsub/yf_pubsub_driver_redis.class.php |
|---|---|
| Use | _class('pubsub_driver_redis', 'classes/pubsub/') |
| Extends | yf_pubsub_driver |
A site sets them in its config with $PROJECT_CONF['pubsub_driver_redis']['NAME'] = ...;
| Property | Default | Description |
|---|---|---|
$_connection |
null |
|
$_connection_pub |
null |
|
$_connection_sub |
null |
|
$_is_connection |
null |
public function conf($params = [])
public function conf($params = [])
{
! $this->_is_connection && $this->connect();
$this->_connection_pub->conf($params);
$this->_connection_sub->conf($params);
return $this;
}
public function connect($options = [])
public function connect($options = [])
{
if ( ! $this->_is_connection) {
if ( ! $options) {
$options = [
'REDIS_HOST' => $this->_get_conf('REDIS_PUBSUB_HOST'),
'REDIS_PORT' => $this->_get_conf('REDIS_PUBSUB_PORT'),
'REDIS_PREFIX' => $this->_get_conf('REDIS_PUBSUB_PREFIX'),
];
}
$this->_connection_pub = redis()->factory($options);
$options['is_new'] = true;
$this->_connection_sub = redis()->factory($options);
$this->_is_connection = true;
}
if ( ! $this->_connection_pub->is_connection()) {
$this->reconnect_pub();
}
if ( ! $this->_connection_sub->is_connection()) {
$this->reconnect_sub();
}
return $this->_is_connection;
}
public function is_ready()
public function is_ready()
{
! $this->_is_connection && $this->connect();
return (bool) $this->_connection;
}
public function pub($channel, $what)
public function pub($channel, $what)
{
! $this->_is_connection && $this->connect();
return $this->_connection_pub->pub($channel, $what);
}
public function pub_conf($params = [])
public function pub_conf($params = [])
{
! $this->_is_connection && $this->connect();
$this->_connection_pub->conf($params);
return $this;
}
public function reconnect_pub()
public function reconnect_pub()
{
$this->_connection_pub->reconnect();
}
public function reconnect_sub()
public function reconnect_sub()
{
$this->_connection_sub->reconnect();
}
public function sub($channels, $callback)
public function sub($channels, $callback)
{
! $this->_is_connection && $this->connect();
return $this->_connection_sub->sub($channels, $callback);
}
public function sub_conf($params = [])
public function sub_conf($params = [])
{
! $this->_is_connection && $this->connect();
$this->_connection_sub->conf($params);
return $this;
}
_ 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_pubsub_driver: __call()