diff --git a/CHANGELOG.md b/CHANGELOG.md index adfb60d..1a3a70b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,23 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com), and this project adheres to [Semantic Versioning](https://semver.org). +## [Unreleased] +### Added +* Add `CacheNamespaceConfigOption` to customize the cache namespace. + +### Changed +* *Nothing* + +### Deprecated +* *Nothing* + +### Removed +* *Nothing* + +### Fixed +* *Nothing* + + ## [8.5.0] - 2023-09-22 ### Added * Improve `init` command's `--initial-api-key` flag, so that it can receive an optional value which will be used as the initial API key. diff --git a/config/config.php b/config/config.php index 5016bf7..c7f6da1 100644 --- a/config/config.php +++ b/config/config.php @@ -92,6 +92,7 @@ 'Delete short URLs > Visits threshold' => Config\Option\Visit\VisitsThresholdConfigOption::class, 'Base path' => Config\Option\BasePathConfigOption::class, 'Timezone' => Config\Option\TimezoneConfigOption::class, + 'Cache > namespace' => Config\Option\Cache\CacheNamespaceConfigOption::class, 'Swoole > Amount of task workers' => Config\Option\Worker\TaskWorkerNumConfigOption::class, 'Swoole > Amount of web workers' => Config\Option\Worker\WebWorkerNumConfigOption::class, ], @@ -115,6 +116,7 @@ 'factories' => [ Config\Option\BasePathConfigOption::class => InvokableFactory::class, Config\Option\TimezoneConfigOption::class => InvokableFactory::class, + Config\Option\Cache\CacheNamespaceConfigOption::class => InvokableFactory::class, Config\Option\Visit\VisitsThresholdConfigOption::class => InvokableFactory::class, Config\Option\Database\DatabaseDriverConfigOption::class => InvokableFactory::class, Config\Option\Database\DatabaseNameConfigOption::class => InvokableFactory::class, diff --git a/src/Config/Option/Cache/CacheNamespaceConfigOption.php b/src/Config/Option/Cache/CacheNamespaceConfigOption.php new file mode 100644 index 0000000..5df9e36 --- /dev/null +++ b/src/Config/Option/Cache/CacheNamespaceConfigOption.php @@ -0,0 +1,25 @@ +ask( + 'Prefix for cache entry keys. (Change this if you run multiple Shlink instances on this server, or they ' + . 'share the same redis instance)', + 'Shlink', + ); + } +} diff --git a/test/Config/Option/Cache/CacheNamespaceConfigOptionTest.php b/test/Config/Option/Cache/CacheNamespaceConfigOptionTest.php new file mode 100644 index 0000000..3ffc2c2 --- /dev/null +++ b/test/Config/Option/Cache/CacheNamespaceConfigOptionTest.php @@ -0,0 +1,41 @@ +configOption = new CacheNamespaceConfigOption(); + } + + #[Test] + public function returnsExpectedEnvVar(): void + { + self::assertEquals('CACHE_NAMESPACE', $this->configOption->getEnvVar()); + } + + #[Test] + public function expectedQuestionIsAsked(): void + { + $io = $this->createMock(StyleInterface::class); + $io->expects($this->once())->method('ask')->with( + 'Prefix for cache entry keys. (Change this if you run multiple Shlink instances on this server, or they ' + . 'share the same redis instance)', + 'Shlink', + )->willReturn('Shlink'); + + $answer = $this->configOption->ask($io, []); + + self::assertEquals('Shlink', $answer); + } +}