Skip to content

Commit 0286d02

Browse files
committed
AC-10860::Investigate colinmollenhour/cache-backend-redis and colinmollenhour/credis latest versions
1 parent 88591ac commit 0286d02

File tree

2 files changed

+38
-17
lines changed

2 files changed

+38
-17
lines changed

setup/src/Magento/Setup/Model/ConfigOptionsList/Cache.php

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class Cache implements ConfigOptionsListInterface
3232
public const INPUT_KEY_CACHE_BACKEND_REDIS_COMPRESS_DATA = 'cache-backend-redis-compress-data';
3333
public const INPUT_KEY_CACHE_BACKEND_REDIS_COMPRESSION_LIB = 'cache-backend-redis-compression-lib';
3434
public const INPUT_KEY_CACHE_BACKEND_REDIS_LUA_KEY = 'cache-backend-redis-lua-key';
35-
public const INPUT_KEY_CACHE_BACKEND_REDIS_LUA_VALUE = 'cache-backend-redis-lua-value';
35+
public const INPUT_KEY_CACHE_BACKEND_REDIS_USE_LUA = 'cache-backend-redis-use-lua';
3636
public const INPUT_KEY_CACHE_ID_PREFIX = 'cache-id-prefix';
3737
public const INPUT_KEY_CACHE_ALLOW_PARALLEL_CACHE_GENERATION = 'allow-parallel-generation';
3838

@@ -43,8 +43,8 @@ class Cache implements ConfigOptionsListInterface
4343
public const CONFIG_PATH_CACHE_BACKEND_PASSWORD = 'cache/frontend/default/backend_options/password';
4444
public const CONFIG_PATH_CACHE_BACKEND_COMPRESS_DATA = 'cache/frontend/default/backend_options/compress_data';
4545
public const CONFIG_PATH_CACHE_BACKEND_COMPRESSION_LIB = 'cache/frontend/default/backend_options/compression_lib';
46-
public const CONFIG_PATH_CACHE_BACKEND_USE_LUA = 'cache/frontend/default/backend_options/_useLua';
47-
public const CONFIG_PATH_CACHE_BACKEND_USE_LUA_VALUE = 'cache/frontend/default/backend_options/use_lua';
46+
public const CONFIG_PATH_CACHE_BACKEND_LUA_KEY = 'cache/frontend/default/backend_options/_useLua';
47+
public const CONFIG_PATH_CACHE_BACKEND_USE_LUA = 'cache/frontend/default/backend_options/use_lua';
4848
public const CONFIG_PATH_CACHE_ID_PREFIX = 'cache/frontend/default/id_prefix';
4949
public const CONFIG_PATH_ALLOW_PARALLEL_CACHE_GENERATION = 'cache/allow_parallel_generation';
5050

@@ -60,7 +60,7 @@ class Cache implements ConfigOptionsListInterface
6060
self::INPUT_KEY_CACHE_BACKEND_REDIS_COMPRESSION_LIB => '',
6161
self::INPUT_KEY_CACHE_ALLOW_PARALLEL_CACHE_GENERATION => 'false',
6262
self::INPUT_KEY_CACHE_BACKEND_REDIS_LUA_KEY => 'true',
63-
self::INPUT_KEY_CACHE_BACKEND_REDIS_LUA_VALUE => 'false'
63+
self::INPUT_KEY_CACHE_BACKEND_REDIS_USE_LUA => 'false'
6464
];
6565

6666
/**
@@ -81,8 +81,8 @@ class Cache implements ConfigOptionsListInterface
8181
self::INPUT_KEY_CACHE_BACKEND_REDIS_COMPRESS_DATA => self::CONFIG_PATH_CACHE_BACKEND_COMPRESS_DATA,
8282
self::INPUT_KEY_CACHE_BACKEND_REDIS_COMPRESSION_LIB => self::CONFIG_PATH_CACHE_BACKEND_COMPRESSION_LIB,
8383
self::INPUT_KEY_CACHE_ALLOW_PARALLEL_CACHE_GENERATION => self::CONFIG_PATH_ALLOW_PARALLEL_CACHE_GENERATION,
84-
self::INPUT_KEY_CACHE_BACKEND_REDIS_LUA_KEY => self::CONFIG_PATH_CACHE_BACKEND_USE_LUA,
85-
self::INPUT_KEY_CACHE_BACKEND_REDIS_LUA_VALUE => self::CONFIG_PATH_CACHE_BACKEND_USE_LUA_VALUE,
84+
self::INPUT_KEY_CACHE_BACKEND_REDIS_LUA_KEY => self::CONFIG_PATH_CACHE_BACKEND_LUA_KEY,
85+
self::INPUT_KEY_CACHE_BACKEND_REDIS_USE_LUA => self::CONFIG_PATH_CACHE_BACKEND_USE_LUA,
8686
];
8787

8888
/**
@@ -149,6 +149,12 @@ public function getOptions()
149149
self::CONFIG_PATH_CACHE_BACKEND_COMPRESSION_LIB,
150150
'Compression lib to use [snappy,lzf,l4z,zstd,gzip] (leave blank to determine automatically)'
151151
),
152+
new TextConfigOption(
153+
self::INPUT_KEY_CACHE_BACKEND_REDIS_USE_LUA,
154+
TextConfigOption::FRONTEND_WIZARD_TEXT,
155+
self::CONFIG_PATH_CACHE_BACKEND_USE_LUA,
156+
'Set to 1 to enable lua (default is 0, disabled)'
157+
),
152158
new TextConfigOption(
153159
self::INPUT_KEY_CACHE_ID_PREFIX,
154160
TextConfigOption::FRONTEND_WIZARD_TEXT,
@@ -263,15 +269,15 @@ private function validateRedisConfig(array $options, DeploymentConfig $deploymen
263269
$config['_useLua'] = isset($options[self::INPUT_KEY_CACHE_BACKEND_REDIS_LUA_KEY])
264270
? $options[self::INPUT_KEY_CACHE_BACKEND_REDIS_LUA_KEY]
265271
: $deploymentConfig->get(
266-
self::CONFIG_PATH_CACHE_BACKEND_USE_LUA,
267-
$this->getDefaultConfigValue(self::CONFIG_PATH_CACHE_BACKEND_USE_LUA)
272+
self::CONFIG_PATH_CACHE_BACKEND_LUA_KEY,
273+
$this->getDefaultConfigValue(self::CONFIG_PATH_CACHE_BACKEND_LUA_KEY)
268274
);
269275

270-
$config['use_lua'] = isset($options[self::INPUT_KEY_CACHE_BACKEND_REDIS_LUA_VALUE])
271-
? $options[self::INPUT_KEY_CACHE_BACKEND_REDIS_LUA_VALUE]
276+
$config['use_lua'] = isset($options[self::INPUT_KEY_CACHE_BACKEND_REDIS_USE_LUA])
277+
? $options[self::INPUT_KEY_CACHE_BACKEND_REDIS_USE_LUA]
272278
: $deploymentConfig->get(
273-
self::CONFIG_PATH_CACHE_BACKEND_USE_LUA_VALUE,
274-
$this->getDefaultConfigValue(self::CONFIG_PATH_CACHE_BACKEND_USE_LUA_VALUE)
279+
self::CONFIG_PATH_CACHE_BACKEND_USE_LUA,
280+
$this->getDefaultConfigValue(self::CONFIG_PATH_CACHE_BACKEND_USE_LUA)
275281
);
276282

277283
return $this->redisValidator->isValidConnection($config);

setup/src/Magento/Setup/Test/Unit/Model/ConfigOptionsList/CacheTest.php

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ protected function setUp(): void
4949
public function testGetOptions()
5050
{
5151
$options = $this->configOptionsList->getOptions();
52-
$this->assertCount(9, $options);
52+
$this->assertCount(10, $options);
5353

5454
$this->assertArrayHasKey(0, $options);
5555
$this->assertInstanceOf(SelectConfigOption::class, $options[0]);
@@ -81,11 +81,15 @@ public function testGetOptions()
8181

8282
$this->assertArrayHasKey(7, $options);
8383
$this->assertInstanceOf(TextConfigOption::class, $options[7]);
84-
$this->assertEquals('cache-id-prefix', $options[7]->getName());
84+
$this->assertEquals('cache-backend-redis-use-lua', $options[7]->getName());
8585

8686
$this->assertArrayHasKey(8, $options);
87-
$this->assertInstanceOf(FlagConfigOption::class, $options[8]);
88-
$this->assertEquals('allow-parallel-generation', $options[8]->getName());
87+
$this->assertInstanceOf(TextConfigOption::class, $options[8]);
88+
$this->assertEquals('cache-id-prefix', $options[8]->getName());
89+
90+
$this->assertArrayHasKey(9, $options);
91+
$this->assertInstanceOf(FlagConfigOption::class, $options[9]);
92+
$this->assertEquals('allow-parallel-generation', $options[9]->getName());
8993
}
9094

9195
/**
@@ -107,6 +111,8 @@ public function testCreateConfigCacheRedis()
107111
'password' => '',
108112
'compress_data' => '',
109113
'compression_lib' => '',
114+
'_useLua' => '',
115+
'use_lua' => ''
110116
],
111117
'id_prefix' => $this->expectedIdPrefix(),
112118
]
@@ -158,6 +164,8 @@ public function testCreateConfigWithRedisConfig()
158164
'password' => '',
159165
'compress_data' => '1',
160166
'compression_lib' => 'gzip',
167+
'_useLua' => null,
168+
'use_lua' => null
161169
],
162170
]
163171
],
@@ -238,7 +246,14 @@ public function testValidateWithValidInput()
238246
];
239247
$this->validatorMock->expects($this->once())
240248
->method('isValidConnection')
241-
->with(['host' => 'localhost', 'db' => '', 'port' => '', 'password' => ''])
249+
->with([
250+
'host' => 'localhost',
251+
'db' => '',
252+
'port' => '',
253+
'password' => '',
254+
'_useLua' => null,
255+
'use_lua' => null
256+
])
242257
->willReturn(true);
243258

244259
$errors = $this->configOptionsList->validate($options, $this->deploymentConfigMock);

0 commit comments

Comments
 (0)