Skip to content

Commit 9cc8966

Browse files
committed
MCLOUD-6958: Command cache:evict does not support L2 cache configuration
1 parent 795a290 commit 9cc8966

File tree

1 file changed

+39
-8
lines changed

1 file changed

+39
-8
lines changed

Model/Cache/Evictor.php

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,7 @@ public function evict(): int
6060
$name
6161
));
6262

63-
if (!isset(
64-
$cacheConfig['backend_options']['server'],
65-
$cacheConfig['backend_options']['port'],
66-
$cacheConfig['backend_options']['database']
67-
)) {
63+
if (!$this->isCacheConfigValid($cacheConfig)) {
6864
$this->logger->debug(sprintf(
6965
'Cache config for database "%s" config is not valid',
7066
$name
@@ -74,9 +70,9 @@ public function evict(): int
7470
}
7571

7672
$dbKeys = $this->run(
77-
(string)$cacheConfig['backend_options']['server'],
78-
(int)$cacheConfig['backend_options']['port'],
79-
(int)$cacheConfig['backend_options']['database']
73+
(string)$this->getCacheConfigValue($name, $cacheConfig, 'server'),
74+
(int)$this->getCacheConfigValue($name, $cacheConfig, 'port'),
75+
(int)$this->getCacheConfigValue($name, $cacheConfig, 'database')
8076
);
8177
$evictedKeys += $dbKeys;
8278

@@ -86,6 +82,41 @@ public function evict(): int
8682
return $evictedKeys;
8783
}
8884

85+
/**
86+
* Get Cache Config Value
87+
*
88+
* @param array $cacheConfig
89+
* @param string $configKey
90+
* @return string
91+
*/
92+
private function getCacheConfigValue($cacheConfig, $configKey)
93+
{
94+
if (isset($cacheConfig['backend_options'][$configKey])) {
95+
return $cacheConfig['backend_options'][$configKey];
96+
}
97+
if (isset($cacheConfig['backend_options']['remote_backend_options'][$configKey])) {
98+
return $cacheConfig['backend_options']['remote_backend_options'][$configKey];
99+
}
100+
return '';
101+
}
102+
103+
/**
104+
* Validate Cache Configuration
105+
*
106+
* @param $cacheConfig
107+
* @return bool
108+
*/
109+
private function isCacheConfigValid($cacheConfig)
110+
{
111+
if ($this->getCacheConfigValue($cacheConfig, 'server')
112+
&& $this->getCacheConfigValue($cacheConfig, 'port')
113+
&& $this->getCacheConfigValue($cacheConfig, 'database')
114+
) {
115+
return true;
116+
}
117+
return false;
118+
}
119+
89120
/**
90121
* @param string $host
91122
* @param int $port

0 commit comments

Comments
 (0)