add option to load the good db for redis

This commit is contained in:
Marion Muszynski 2017-09-25 12:24:44 +02:00
parent 4435a061e2
commit cab30809b1

View File

@ -23,6 +23,7 @@ class CacheRedis
private $auth;
private $port;
private $host;
private $db;
private $redis_client;
private $default_ttl;
private $short_ttl;
@ -41,6 +42,7 @@ class CacheRedis
$this->auth = _REDIS_AUTH_STRING_;
$this->host = _REDIS_HOST_STRING_;
$this->port = _REDIS_PORT_STRING_;
$this->db = _REDIS_DB_STRING_;
$this->default_ttl = _REDIS_DEFAULT_TTL_;
$this->short_ttl = defined('_REDIS_SHORT_TTL_') ? _REDIS_SHORT_TTL_ : _REDIS_DEFAULT_TTL_;
$this->medium_ttl = defined('_REDIS_MEDIUM_TTL_') ? _REDIS_MEDIUM_TTL_ : _REDIS_DEFAULT_TTL_;
@ -51,11 +53,19 @@ class CacheRedis
'host' => $this->host,
'port' => $this->port,
'password' => $this->auth,
],
['parameters' => [
'database' => (int)$this->db,
],
]);
} else {
$this->redis_client = new Predis\Client(['scheme' => 'tcp',
'host' => $this->host,
'port' => $this->port,
],
['parameters' => [
'database' => (int)$this->db,
],
]);
}
try {