diff --git a/setup/src/Magento/Setup/Model/ConfigOptionsList/Cache.php b/setup/src/Magento/Setup/Model/ConfigOptionsList/Cache.php index 173064b472217..89a37429c47c9 100644 --- a/setup/src/Magento/Setup/Model/ConfigOptionsList/Cache.php +++ b/setup/src/Magento/Setup/Model/ConfigOptionsList/Cache.php @@ -27,6 +27,8 @@ class Cache implements ConfigOptionsListInterface const INPUT_KEY_CACHE_BACKEND_REDIS_DATABASE = 'cache-backend-redis-db'; const INPUT_KEY_CACHE_BACKEND_REDIS_PORT = 'cache-backend-redis-port'; const INPUT_KEY_CACHE_BACKEND_REDIS_PASSWORD = 'cache-backend-redis-password'; + const INPUT_KEY_CACHE_BACKEND_REDIS_COMPRESS_DATA = 'cache-backend-redis-compress-data'; + const INPUT_KEY_CACHE_BACKEND_REDIS_COMPRESSION_LIB = 'cache-backend-redis-compression-lib'; const INPUT_KEY_CACHE_ID_PREFIX = 'cache-id-prefix'; const CONFIG_PATH_CACHE_BACKEND = 'cache/frontend/default/backend'; @@ -34,6 +36,8 @@ class Cache implements ConfigOptionsListInterface const CONFIG_PATH_CACHE_BACKEND_DATABASE = 'cache/frontend/default/backend_options/database'; const CONFIG_PATH_CACHE_BACKEND_PORT = 'cache/frontend/default/backend_options/port'; const CONFIG_PATH_CACHE_BACKEND_PASSWORD = 'cache/frontend/default/backend_options/password'; + const CONFIG_PATH_CACHE_BACKEND_COMPRESS_DATA = 'cache/frontend/default/backend_options/compress_data'; + const CONFIG_PATH_CACHE_BACKEND_COMPRESSION_LIB = 'cache/frontend/default/backend_options/compression_lib'; const CONFIG_PATH_CACHE_ID_PREFIX = 'cache/frontend/default/id_prefix'; /** @@ -43,7 +47,9 @@ class Cache implements ConfigOptionsListInterface self::INPUT_KEY_CACHE_BACKEND_REDIS_SERVER => '127.0.0.1', self::INPUT_KEY_CACHE_BACKEND_REDIS_DATABASE => '0', self::INPUT_KEY_CACHE_BACKEND_REDIS_PORT => '6379', - self::INPUT_KEY_CACHE_BACKEND_REDIS_PASSWORD => '' + self::INPUT_KEY_CACHE_BACKEND_REDIS_PASSWORD => '', + self::INPUT_KEY_CACHE_BACKEND_REDIS_COMPRESS_DATA => '1', + self::INPUT_KEY_CACHE_BACKEND_REDIS_COMPRESSION_LIB => '', ]; /** @@ -60,7 +66,9 @@ class Cache implements ConfigOptionsListInterface self::INPUT_KEY_CACHE_BACKEND_REDIS_SERVER => self::CONFIG_PATH_CACHE_BACKEND_SERVER, self::INPUT_KEY_CACHE_BACKEND_REDIS_DATABASE => self::CONFIG_PATH_CACHE_BACKEND_DATABASE, self::INPUT_KEY_CACHE_BACKEND_REDIS_PORT => self::CONFIG_PATH_CACHE_BACKEND_PORT, - self::INPUT_KEY_CACHE_BACKEND_REDIS_PASSWORD => self::CONFIG_PATH_CACHE_BACKEND_PASSWORD + self::INPUT_KEY_CACHE_BACKEND_REDIS_PASSWORD => self::CONFIG_PATH_CACHE_BACKEND_PASSWORD, + self::INPUT_KEY_CACHE_BACKEND_REDIS_COMPRESS_DATA => self::CONFIG_PATH_CACHE_BACKEND_COMPRESS_DATA, + self::INPUT_KEY_CACHE_BACKEND_REDIS_COMPRESSION_LIB => self::CONFIG_PATH_CACHE_BACKEND_COMPRESSION_LIB, ]; /** @@ -115,12 +123,24 @@ public function getOptions() self::CONFIG_PATH_CACHE_BACKEND_PASSWORD, 'Redis server password' ), + new TextConfigOption( + self::INPUT_KEY_CACHE_BACKEND_REDIS_COMPRESS_DATA, + TextConfigOption::FRONTEND_WIZARD_TEXT, + self::CONFIG_PATH_CACHE_BACKEND_COMPRESS_DATA, + 'Set to 0 to disable compression (default is 1, enabled)' + ), + new TextConfigOption( + self::INPUT_KEY_CACHE_BACKEND_REDIS_COMPRESSION_LIB, + TextConfigOption::FRONTEND_WIZARD_TEXT, + self::CONFIG_PATH_CACHE_BACKEND_COMPRESSION_LIB, + 'Compression lib to use [snappy,lzf,l4z,zstd,gzip] (leave blank to determine automatically)' + ), new TextConfigOption( self::INPUT_KEY_CACHE_ID_PREFIX, TextConfigOption::FRONTEND_WIZARD_TEXT, self::CONFIG_PATH_CACHE_ID_PREFIX, 'ID prefix for cache keys' - ) + ), ]; } diff --git a/setup/src/Magento/Setup/Model/ConfigOptionsList/PageCache.php b/setup/src/Magento/Setup/Model/ConfigOptionsList/PageCache.php index 7451b59356828..65bfc650c0206 100644 --- a/setup/src/Magento/Setup/Model/ConfigOptionsList/PageCache.php +++ b/setup/src/Magento/Setup/Model/ConfigOptionsList/PageCache.php @@ -6,10 +6,10 @@ namespace Magento\Setup\Model\ConfigOptionsList; -use Magento\Framework\Setup\ConfigOptionsListInterface; -use Magento\Framework\Config\File\ConfigFilePool; use Magento\Framework\App\DeploymentConfig; use Magento\Framework\Config\Data\ConfigData; +use Magento\Framework\Config\File\ConfigFilePool; +use Magento\Framework\Setup\ConfigOptionsListInterface; use Magento\Framework\Setup\Option\SelectConfigOption; use Magento\Framework\Setup\Option\TextConfigOption; use Magento\Setup\Validator\RedisConnectionValidator; @@ -26,16 +26,18 @@ class PageCache implements ConfigOptionsListInterface const INPUT_KEY_PAGE_CACHE_BACKEND_REDIS_SERVER = 'page-cache-redis-server'; const INPUT_KEY_PAGE_CACHE_BACKEND_REDIS_DATABASE = 'page-cache-redis-db'; const INPUT_KEY_PAGE_CACHE_BACKEND_REDIS_PORT = 'page-cache-redis-port'; - const INPUT_KEY_PAGE_CACHE_BACKEND_REDIS_COMPRESS_DATA = 'page-cache-redis-compress-data'; const INPUT_KEY_PAGE_CACHE_BACKEND_REDIS_PASSWORD = 'page-cache-redis-password'; + const INPUT_KEY_PAGE_CACHE_BACKEND_REDIS_COMPRESS_DATA = 'page-cache-redis-compress-data'; + const INPUT_KEY_PAGE_CACHE_BACKEND_REDIS_COMPRESSION_LIB = 'page-cache-redis-compression-lib'; const INPUT_KEY_PAGE_CACHE_ID_PREFIX = 'page-cache-id-prefix'; const CONFIG_PATH_PAGE_CACHE_BACKEND = 'cache/frontend/page_cache/backend'; const CONFIG_PATH_PAGE_CACHE_BACKEND_SERVER = 'cache/frontend/page_cache/backend_options/server'; const CONFIG_PATH_PAGE_CACHE_BACKEND_DATABASE = 'cache/frontend/page_cache/backend_options/database'; const CONFIG_PATH_PAGE_CACHE_BACKEND_PORT = 'cache/frontend/page_cache/backend_options/port'; - const CONFIG_PATH_PAGE_CACHE_BACKEND_COMPRESS_DATA = 'cache/frontend/page_cache/backend_options/compress_data'; const CONFIG_PATH_PAGE_CACHE_BACKEND_PASSWORD = 'cache/frontend/page_cache/backend_options/password'; + const CONFIG_PATH_PAGE_CACHE_BACKEND_COMPRESS_DATA = 'cache/frontend/page_cache/backend_options/compress_data'; + const CONFIG_PATH_PAGE_CACHE_BACKEND_COMPRESSION_LIB = 'cache/frontend/page_cache/backend_options/compression_lib'; const CONFIG_PATH_PAGE_CACHE_ID_PREFIX = 'cache/frontend/page_cache/id_prefix'; /** @@ -45,8 +47,9 @@ class PageCache implements ConfigOptionsListInterface self::INPUT_KEY_PAGE_CACHE_BACKEND_REDIS_SERVER => '127.0.0.1', self::INPUT_KEY_PAGE_CACHE_BACKEND_REDIS_DATABASE => '1', self::INPUT_KEY_PAGE_CACHE_BACKEND_REDIS_PORT => '6379', + self::INPUT_KEY_PAGE_CACHE_BACKEND_REDIS_PASSWORD => '', self::INPUT_KEY_PAGE_CACHE_BACKEND_REDIS_COMPRESS_DATA => '0', - self::INPUT_KEY_PAGE_CACHE_BACKEND_REDIS_PASSWORD => '' + self::INPUT_KEY_PAGE_CACHE_BACKEND_REDIS_COMPRESSION_LIB => '', ]; /** @@ -63,8 +66,10 @@ class PageCache implements ConfigOptionsListInterface self::INPUT_KEY_PAGE_CACHE_BACKEND_REDIS_SERVER => self::CONFIG_PATH_PAGE_CACHE_BACKEND_SERVER, self::INPUT_KEY_PAGE_CACHE_BACKEND_REDIS_DATABASE => self::CONFIG_PATH_PAGE_CACHE_BACKEND_DATABASE, self::INPUT_KEY_PAGE_CACHE_BACKEND_REDIS_PORT => self::CONFIG_PATH_PAGE_CACHE_BACKEND_PORT, + self::INPUT_KEY_PAGE_CACHE_BACKEND_REDIS_PASSWORD => self::CONFIG_PATH_PAGE_CACHE_BACKEND_PASSWORD, self::INPUT_KEY_PAGE_CACHE_BACKEND_REDIS_COMPRESS_DATA => self::CONFIG_PATH_PAGE_CACHE_BACKEND_COMPRESS_DATA, - self::INPUT_KEY_PAGE_CACHE_BACKEND_REDIS_PASSWORD => self::CONFIG_PATH_PAGE_CACHE_BACKEND_PASSWORD + self::INPUT_KEY_PAGE_CACHE_BACKEND_REDIS_COMPRESSION_LIB => + self::CONFIG_PATH_PAGE_CACHE_BACKEND_COMPRESSION_LIB, ]; /** @@ -113,6 +118,12 @@ public function getOptions() self::CONFIG_PATH_PAGE_CACHE_BACKEND_PORT, 'Redis server listen port' ), + new TextConfigOption( + self::INPUT_KEY_PAGE_CACHE_BACKEND_REDIS_PASSWORD, + TextConfigOption::FRONTEND_WIZARD_TEXT, + self::CONFIG_PATH_PAGE_CACHE_BACKEND_PASSWORD, + 'Redis server password' + ), new TextConfigOption( self::INPUT_KEY_PAGE_CACHE_BACKEND_REDIS_COMPRESS_DATA, TextConfigOption::FRONTEND_WIZARD_TEXT, @@ -120,17 +131,17 @@ public function getOptions() 'Set to 1 to compress the full page cache (use 0 to disable)' ), new TextConfigOption( - self::INPUT_KEY_PAGE_CACHE_BACKEND_REDIS_PASSWORD, + self::INPUT_KEY_PAGE_CACHE_BACKEND_REDIS_COMPRESSION_LIB, TextConfigOption::FRONTEND_WIZARD_TEXT, - self::CONFIG_PATH_PAGE_CACHE_BACKEND_PASSWORD, - 'Redis server password' + self::CONFIG_PATH_PAGE_CACHE_BACKEND_COMPRESSION_LIB, + 'Compression library to use [snappy,lzf,l4z,zstd,gzip] (leave blank to determine automatically)' ), new TextConfigOption( self::INPUT_KEY_PAGE_CACHE_ID_PREFIX, TextConfigOption::FRONTEND_WIZARD_TEXT, self::CONFIG_PATH_PAGE_CACHE_ID_PREFIX, 'ID prefix for cache keys' - ) + ), ]; } @@ -224,7 +235,7 @@ private function validateRedisConfig(array $options, DeploymentConfig $deploymen self::CONFIG_PATH_PAGE_CACHE_BACKEND_DATABASE, $this->getDefaultConfigValue(self::INPUT_KEY_PAGE_CACHE_BACKEND_REDIS_DATABASE) ); - + $config['password'] = isset($options[self::INPUT_KEY_PAGE_CACHE_BACKEND_REDIS_PASSWORD]) ? $options[self::INPUT_KEY_PAGE_CACHE_BACKEND_REDIS_PASSWORD] : $deploymentConfig->get( diff --git a/setup/src/Magento/Setup/Test/Unit/Model/ConfigOptionsList/CacheTest.php b/setup/src/Magento/Setup/Test/Unit/Model/ConfigOptionsList/CacheTest.php index 9c123fcb330dd..783c11e941eed 100644 --- a/setup/src/Magento/Setup/Test/Unit/Model/ConfigOptionsList/CacheTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/ConfigOptionsList/CacheTest.php @@ -45,7 +45,7 @@ protected function setUp() public function testGetOptions() { $options = $this->configOptionsList->getOptions(); - $this->assertCount(6, $options); + $this->assertCount(8, $options); $this->assertArrayHasKey(0, $options); $this->assertInstanceOf(SelectConfigOption::class, $options[0]); @@ -69,7 +69,15 @@ public function testGetOptions() $this->assertArrayHasKey(5, $options); $this->assertInstanceOf(TextConfigOption::class, $options[5]); - $this->assertEquals('cache-id-prefix', $options[5]->getName()); + $this->assertEquals('cache-backend-redis-compress-data', $options[5]->getName()); + + $this->assertArrayHasKey(6, $options); + $this->assertInstanceOf(TextConfigOption::class, $options[6]); + $this->assertEquals('cache-backend-redis-compression-lib', $options[6]->getName()); + + $this->assertArrayHasKey(7, $options); + $this->assertInstanceOf(TextConfigOption::class, $options[7]); + $this->assertEquals('cache-id-prefix', $options[7]->getName()); } /** @@ -88,7 +96,9 @@ public function testCreateConfigCacheRedis() 'server' => '', 'port' => '', 'database' => '', - 'password' => '' + 'password' => '', + 'compress_data' => '', + 'compression_lib' => '', ], 'id_prefix' => $this->expectedIdPrefix(), ] @@ -115,18 +125,23 @@ public function testCreateConfigWithRedisConfig() 'server' => 'localhost', 'port' => '1234', 'database' => '5', - 'password' => '' + 'password' => '', + 'compress_data' => '1', + 'compression_lib' => 'gzip', ], 'id_prefix' => $this->expectedIdPrefix(), ] ] ] ]; + $options = [ 'cache-backend' => 'redis', 'cache-backend-redis-server' => 'localhost', 'cache-backend-redis-port' => '1234', - 'cache-backend-redis-db' => '5' + 'cache-backend-redis-db' => '5', + 'cache-backend-redis-compress-data' => '1', + 'cache-backend-redis-compression-lib' => 'gzip' ]; $configData = $this->configOptionsList->createConfig($options, $this->deploymentConfigMock); diff --git a/setup/src/Magento/Setup/Test/Unit/Model/ConfigOptionsList/PageCacheTest.php b/setup/src/Magento/Setup/Test/Unit/Model/ConfigOptionsList/PageCacheTest.php index 1cf3937f98684..673168fe2fffd 100644 --- a/setup/src/Magento/Setup/Test/Unit/Model/ConfigOptionsList/PageCacheTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/ConfigOptionsList/PageCacheTest.php @@ -45,7 +45,7 @@ protected function setUp() public function testGetOptions() { $options = $this->configList->getOptions(); - $this->assertCount(7, $options); + $this->assertCount(8, $options); $this->assertArrayHasKey(0, $options); $this->assertInstanceOf(SelectConfigOption::class, $options[0]); @@ -65,15 +65,19 @@ public function testGetOptions() $this->assertArrayHasKey(4, $options); $this->assertInstanceOf(TextConfigOption::class, $options[4]); - $this->assertEquals('page-cache-redis-compress-data', $options[4]->getName()); + $this->assertEquals('page-cache-redis-password', $options[4]->getName()); $this->assertArrayHasKey(5, $options); $this->assertInstanceOf(TextConfigOption::class, $options[5]); - $this->assertEquals('page-cache-redis-password', $options[5]->getName()); + $this->assertEquals('page-cache-redis-compress-data', $options[5]->getName()); $this->assertArrayHasKey(6, $options); $this->assertInstanceOf(TextConfigOption::class, $options[6]); - $this->assertEquals('page-cache-id-prefix', $options[6]->getName()); + $this->assertEquals('page-cache-redis-compression-lib', $options[6]->getName()); + + $this->assertArrayHasKey(7, $options); + $this->assertInstanceOf(TextConfigOption::class, $options[7]); + $this->assertEquals('page-cache-id-prefix', $options[7]->getName()); } /** @@ -93,7 +97,8 @@ public function testCreateConfigWithRedis() 'port' => '', 'database' => '', 'compress_data' => '', - 'password' => '' + 'password' => '', + 'compression_lib' => '', ], 'id_prefix' => $this->expectedIdPrefix(), ] @@ -120,8 +125,9 @@ public function testCreateConfigWithRedisConfiguration() 'server' => 'foo.bar', 'port' => '9000', 'database' => '6', + 'password' => '', 'compress_data' => '1', - 'password' => '' + 'compression_lib' => 'gzip', ], 'id_prefix' => $this->expectedIdPrefix(), ] @@ -134,7 +140,8 @@ public function testCreateConfigWithRedisConfiguration() 'page-cache-redis-server' => 'foo.bar', 'page-cache-redis-port' => '9000', 'page-cache-redis-db' => '6', - 'page-cache-redis-compress-data' => '1' + 'page-cache-redis-compress-data' => '1', + 'page-cache-redis-compression-lib' => 'gzip', ]; $configData = $this->configList->createConfig($options, $this->deploymentConfigMock);