NOW MANAGED ON CODEBERG
Updated redis config logic, Now takes a password
Dan Brown646fd822c5e3
diff --git a/.env.example.complete b/.env.example.completeindex 8851bd268..77a0508dc 100644--- a/.env.example.complete+++ b/.env.example.complete@@ -75,6 +75,12 @@ CACHE_PREFIX=bookstack# For multiple servers separate with a commaMEMCACHED_SERVERS=127.0.0.1:11211:100+# Redis server configuration+# This follows the following format: HOST:PORT:DATABASE+# or, if using a password: HOST:PORT:DATABASE:PASSWORD+# For multiple servers separate with a comma. These will be clustered.+REDIS_SERVERS=127.0.0.1:6379:0+# Queue driver to use# Queue not really currently used but may be configurable in the future.# Would advise not to change this for now.diff --git a/config/database.php b/config/database.phpindex 6ca902944..93a44854f 100644--- a/config/database.php+++ b/config/database.php@@ -8,23 +8,39 @@* Do not edit this file unless you're happy to maintain any changes yourself.*/-// REDIS - Split out configuration into an array+// REDIS+// Split out configuration into an arrayif (env('REDIS_SERVERS', false)) {- $redisServerKeys = ['host', 'port', 'database'];++ $redisDefaults = ['host' => '127.0.0.1', 'port' => '6379', 'database' => '0', 'password' => null];$redisServers = explode(',', trim(env('REDIS_SERVERS', '127.0.0.1:6379:0'), ','));- $redisConfig = [- 'cluster' => env('REDIS_CLUSTER', false)- ];+ $redisConfig = [];+ $cluster = count($redisServers) > 1;++ if ($cluster) {+ $redisConfig['clusters'] = ['default' => []];+ }+foreach ($redisServers as $index => $redisServer) {- $redisServerName = ($index === 0) ? 'default' : 'redis-server-' . $index;$redisServerDetails = explode(':', $redisServer);- if (count($redisServerDetails) < 2) $redisServerDetails[] = '6379';- if (count($redisServerDetails) < 3) $redisServerDetails[] = '0';- $redisConfig[$redisServerName] = array_combine($redisServerKeys, $redisServerDetails);++ $serverConfig = [];+ $configIndex = 0;+ foreach ($redisDefaults as $configKey => $configDefault) {+ $serverConfig[$configKey] = ($redisServerDetails[$configIndex] ?? $configDefault);+ $configIndex++;+ }++ if ($cluster) {+ $redisConfig['clusters']['default'][] = $serverConfig;+ } else {+ $redisConfig['default'] = $serverConfig;+ }}}-// MYSQL - Split out port from host if set+// MYSQL+// Split out port from host if set$mysql_host = env('DB_HOST', 'localhost');$mysql_host_exploded = explode(':', $mysql_host);$mysql_port = env('DB_PORT', 3306);