From 29b747c192290db2a8d39489cd3f7a4861720346 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sat, 10 Dec 2022 10:11:25 +0100 Subject: [PATCH] Added missing namespace for cache adapters, causing full cache to be flushed in some circumstances --- CHANGELOG.md | 1 + config/autoload/redis.global.php | 23 ++++++++++------------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0fa211ec..3a944d90 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com), and this ### Fixed * [#1618](https://github.com/shlinkio/shlink/issues/1618) Fixed imported short URLs and visits dates not being set to the target server timezone. * [#1578](https://github.com/shlinkio/shlink/issues/1578) Fixed short URL allowing an empty string as the domain during creation. +* [#1580](https://github.com/shlinkio/shlink/issues/1580) Fixed `FLUSHDB` being run on Shlink docker start-up when using redis, causing full cache to be flushed. ## [3.3.2] - 2022-10-18 diff --git a/config/autoload/redis.global.php b/config/autoload/redis.global.php index 1d035055..614b140f 100644 --- a/config/autoload/redis.global.php +++ b/config/autoload/redis.global.php @@ -6,22 +6,19 @@ use Shlinkio\Shlink\Core\Config\EnvVars; return (static function (): array { $redisServers = EnvVars::REDIS_SERVERS->loadFromEnv(); - $pubSub = [ + $redis = ['pub_sub_enabled' => $redisServers !== null && EnvVars::REDIS_PUB_SUB_ENABLED->loadFromEnv(false)]; + $cacheRedisBlock = $redisServers === null ? [] : [ 'redis' => [ - 'pub_sub_enabled' => $redisServers !== null && EnvVars::REDIS_PUB_SUB_ENABLED->loadFromEnv(false), + 'servers' => $redisServers, + 'sentinel_service' => EnvVars::REDIS_SENTINEL_SERVICE->loadFromEnv(), ], ]; - return match ($redisServers) { - null => $pubSub, - default => [ - 'cache' => [ - 'redis' => [ - 'servers' => $redisServers, - 'sentinel_service' => EnvVars::REDIS_SENTINEL_SERVICE->loadFromEnv(), - ], - ], - ...$pubSub, + return [ + 'cache' => [ + 'namespace' => 'Shlink', + ...$cacheRedisBlock, ], - }; + 'redis' => $redis, + ]; })();