Skip to content

Instantly share code, notes, and snippets.

@nelson-ph
Last active April 30, 2021 13:10
Show Gist options
  • Save nelson-ph/bb2d6357cbaedb555954c6b0b4248584 to your computer and use it in GitHub Desktop.
Save nelson-ph/bb2d6357cbaedb555954c6b0b4248584 to your computer and use it in GitHub Desktop.
Simplesaml - redis cluster support
Index: lib/SimpleSAML/Store/Redis.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/lib/SimpleSAML/Store/Redis.php b/lib/SimpleSAML/Store/Redis.php
--- a/lib/SimpleSAML/Store/Redis.php (date 1619776407367)
+++ b/lib/SimpleSAML/Store/Redis.php (date 1619776407367)
@@ -38,17 +38,31 @@
$password = $config->getString('store.redis.password', '');
$database = $config->getInteger('store.redis.database', 0);
- $redis = new Client(
+ $hosts = $config->getArray('store.redis.hosts', []);
+
+ if(!empty($hosts)){
+ $options = $config->getArray('store.redis.options', []);
+ $redis = new Client(
+ $hosts,
+ [
+ 'prefix' => $prefix,
+ 'cluster' => 'redis'
+ ] + $options
+ );
+ }
+ if(empty($hosts)){
+ $redis = new Client(
[
- 'scheme' => 'tcp',
- 'host' => $host,
- 'port' => $port,
- 'database' => $database,
+ 'scheme' => 'tcp',
+ 'host' => $host,
+ 'port' => $port,
+ 'database' => $database,
] + (!empty($password) ? ['password' => $password] : []),
[
- 'prefix' => $prefix,
+ 'prefix' => $prefix,
]
- );
+ );
+ }
}
$this->redis = $redis;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment