Added support for redis password option #1620

This commit is contained in:
Andy Miller
2017-08-24 09:17:25 -06:00
parent 04690ce206
commit cc8a20537e
3 changed files with 13 additions and 0 deletions

View File

@@ -4,6 +4,7 @@
1. [](#improved)
* Forced `natsort` on plugins to ensure consistent plugin load ordering across platforms [#1614](https://github.com/getgrav/grav/issues/1614)
* Use new `multilevel` field to handle Asset Collections [#1201](https://github.com/getgrav/grav-plugin-admin/issues/1201)
* Added support for redis `password` option [#1620](https://github.com/getgrav/grav/issues/1620)
# v1.3.2
## 08/16/2017

View File

@@ -616,6 +616,12 @@ form:
help: PLUGIN_ADMIN.REDIS_PORT_HELP
placeholder: "6379"
cache.redis.password:
type: text
size: small
label: PLUGIN_ADMIN.REDIS_PASSWORD
twig:
type: section

View File

@@ -240,6 +240,7 @@ class Cache extends Getters
case 'redis':
$redis = new \Redis();
$socket = $this->config->get('system.cache.redis.socket', false);
$password = $this->config->get('system.cache.redis.password', false);
if ($socket) {
$redis->connect($socket);
@@ -248,6 +249,11 @@ class Cache extends Getters
$this->config->get('system.cache.redis.port', 6379));
}
// Authenticate with password if set
if ($password && !$redis->auth($password)) {
throw new \RedisException('Redis authentication failed');
}
$driver = new DoctrineCache\RedisCache();
$driver->setRedis($redis);
break;