mirror of
https://github.com/getgrav/grav.git
synced 2025-02-20 19:56:53 +01:00
Support selecting Redis database ID (#3208)
This commit is contained in:
parent
c3ebd529c1
commit
51cc9cd13e
|
|
@ -296,6 +296,7 @@ class Cache extends Getters
|
|||
$redis = new \Redis();
|
||||
$socket = $this->config->get('system.cache.redis.socket', false);
|
||||
$password = $this->config->get('system.cache.redis.password', false);
|
||||
$databaseId = $this->config->get('system.cache.redis.database', 0);
|
||||
|
||||
if ($socket) {
|
||||
$redis->connect($socket);
|
||||
|
|
@ -310,6 +311,11 @@ class Cache extends Getters
|
|||
if ($password && !$redis->auth($password)) {
|
||||
throw new \RedisException('Redis authentication failed');
|
||||
}
|
||||
|
||||
// Select alternate ( !=0 ) database ID if set
|
||||
if ($databaseId && !$redis->select($databaseId)) {
|
||||
throw new \RedisException('Could not select alternate Redis database ID');
|
||||
}
|
||||
|
||||
$driver = new DoctrineCache\RedisCache();
|
||||
$driver->setRedis($redis);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user