Skip to content

Commit

Permalink
Added support for redis password option #1620
Browse files Browse the repository at this point in the history
  • Loading branch information
rhukster committed Aug 24, 2017
1 parent 04690ce commit cc8a205
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions system/blueprints/config/system.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions system/src/Grav/Common/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ public function getCacheDriver()
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);
Expand All @@ -248,6 +249,11 @@ public function getCacheDriver()
$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;
Expand Down

0 comments on commit cc8a205

Please sign in to comment.