mirror of
https://github.com/getgrav/grav.git
synced 2026-01-24 00:09:51 +01:00
Support selecting Redis database ID (#3208)
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user