From 4fadd523f193d568e558c1e5b52643b8807599d4 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sun, 5 Jan 2020 16:45:14 +0100 Subject: [PATCH] Updated config to read redis from config.redis --- config/autoload/redis.local.php.local | 13 ++++++++----- docker/config/shlink_in_docker.local.php | 10 ++++++++-- module/Core/src/Config/SimplifiedConfigParser.php | 2 +- .../Core/test/Config/SimplifiedConfigParserTest.php | 10 ++++++---- 4 files changed, 23 insertions(+), 12 deletions(-) diff --git a/config/autoload/redis.local.php.local b/config/autoload/redis.local.php.local index f89201f1..08dbae32 100644 --- a/config/autoload/redis.local.php.local +++ b/config/autoload/redis.local.php.local @@ -1,13 +1,16 @@ [ - 'servers' => 'tcp://shlink_redis:6379', -// 'servers' => [ -// 'tcp://shlink_redis:6379', -// ], + 'cache' => [ + 'redis' => [ + 'servers' => 'tcp://shlink_redis:6379', +// 'servers' => [ +// 'tcp://shlink_redis:6379', +// ], + ], ], 'dependencies' => [ diff --git a/docker/config/shlink_in_docker.local.php b/docker/config/shlink_in_docker.local.php index 0da6a9e5..7eba5560 100644 --- a/docker/config/shlink_in_docker.local.php +++ b/docker/config/shlink_in_docker.local.php @@ -62,6 +62,12 @@ $helper = new class { $webhooks = env('VISITS_WEBHOOKS'); return $webhooks === null ? [] : explode(',', $webhooks); } + + public function getRedisConfig(): ?array + { + $redisServers = env('REDIS_SERVERS'); + return $redisServers === null ? null : ['servers' => $redisServers]; + } }; return [ @@ -112,8 +118,8 @@ return [ ], ], - 'redis' => [ - 'servers' => env('REDIS_SERVERS'), + 'cache' => [ + 'redis' => $helper->getRedisConfig(), ], 'router' => [ diff --git a/module/Core/src/Config/SimplifiedConfigParser.php b/module/Core/src/Config/SimplifiedConfigParser.php index 651066d4..fa7a4acb 100644 --- a/module/Core/src/Config/SimplifiedConfigParser.php +++ b/module/Core/src/Config/SimplifiedConfigParser.php @@ -27,7 +27,7 @@ class SimplifiedConfigParser 'base_url_redirect_to' => ['not_found_redirects', 'base_path'], 'db_config' => ['entity_manager', 'connection'], 'delete_short_url_threshold' => ['delete_short_urls', 'visits_threshold'], - 'redis_servers' => ['redis', 'servers'], + 'redis_servers' => ['cache', 'redis', 'servers'], 'base_path' => ['router', 'base_path'], 'web_worker_num' => ['mezzio-swoole', 'swoole-http-server', 'options', 'worker_num'], 'task_worker_num' => ['mezzio-swoole', 'swoole-http-server', 'options', 'task_worker_num'], diff --git a/module/Core/test/Config/SimplifiedConfigParserTest.php b/module/Core/test/Config/SimplifiedConfigParserTest.php index d92399cf..1d4f3b8d 100644 --- a/module/Core/test/Config/SimplifiedConfigParserTest.php +++ b/module/Core/test/Config/SimplifiedConfigParserTest.php @@ -97,10 +97,12 @@ class SimplifiedConfigParserTest extends TestCase ], ], - 'redis' => [ - 'servers' => [ - 'tcp://1.1.1.1:1111', - 'tcp://1.2.2.2:2222', + 'cache' => [ + 'redis' => [ + 'servers' => [ + 'tcp://1.1.1.1:1111', + 'tcp://1.2.2.2:2222', + ], ], ],