diff --git a/system/src/Grav/Common/Cache.php b/system/src/Grav/Common/Cache.php index dea370ff6..24f1d4010 100644 --- a/system/src/Grav/Common/Cache.php +++ b/system/src/Grav/Common/Cache.php @@ -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);