# For multiple servers separate with a comma
MEMCACHED_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.
* 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 array
if (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);