diff --git a/app/Config/Cache.php b/app/Config/Cache.php index 15038399a43e..015bd6fd68c4 100644 --- a/app/Config/Cache.php +++ b/app/Config/Cache.php @@ -97,6 +97,7 @@ class Cache extends BaseConfig 'password' => null, 'port' => 6379, 'timeout' => 0, + 'database' => 0, ]; /* diff --git a/system/Cache/Handlers/RedisHandler.php b/system/Cache/Handlers/RedisHandler.php index 57792e7a9af4..793edb761fd4 100644 --- a/system/Cache/Handlers/RedisHandler.php +++ b/system/Cache/Handlers/RedisHandler.php @@ -60,6 +60,7 @@ class RedisHandler implements CacheInterface 'password' => null, 'port' => 6379, 'timeout' => 0, + 'database' => 0, ]; /** @@ -118,6 +119,11 @@ public function initialize() { // log_message('error', 'Cache: Redis authentication failed.'); } + + if (isset($config['database']) && ! $this->redis->select($config['database'])) + { + log_message('error', 'Cache: Redis select database failed.'); + } } catch (\RedisException $e) { diff --git a/user_guide_src/source/libraries/caching.rst b/user_guide_src/source/libraries/caching.rst index 28765401ce47..1ebbcd0374b0 100644 --- a/user_guide_src/source/libraries/caching.rst +++ b/user_guide_src/source/libraries/caching.rst @@ -246,6 +246,7 @@ Available options are:: $config['password'] = NULL; $config['port'] = 6379; $config['timeout'] = 0; + $config['database'] = 0; For more information on Redis, please see `http://redis.io `_.