Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 39 additions & 8 deletions Model/Cache/Evictor.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,7 @@ public function evict(): int
$name
));

if (!isset(
$cacheConfig['backend_options']['server'],
$cacheConfig['backend_options']['port'],
$cacheConfig['backend_options']['database']
)) {
if (!$this->isCacheConfigValid($cacheConfig)) {
$this->logger->debug(sprintf(
'Cache config for database "%s" config is not valid',
$name
Expand All @@ -74,9 +70,9 @@ public function evict(): int
}

$dbKeys = $this->run(
(string)$cacheConfig['backend_options']['server'],
(int)$cacheConfig['backend_options']['port'],
(int)$cacheConfig['backend_options']['database']
(string)$this->getCacheConfigValue($name, $cacheConfig, 'server'),
(int)$this->getCacheConfigValue($name, $cacheConfig, 'port'),
(int)$this->getCacheConfigValue($name, $cacheConfig, 'database')
);
$evictedKeys += $dbKeys;

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

/**
* Get Cache Config Value
*
* @param array $cacheConfig
* @param string $configKey
* @return string
*/
private function getCacheConfigValue($cacheConfig, $configKey): string
{
if (isset($cacheConfig['backend_options'][$configKey])) {
return $cacheConfig['backend_options'][$configKey];
}
if (isset($cacheConfig['backend_options']['remote_backend_options'][$configKey])) {
return $cacheConfig['backend_options']['remote_backend_options'][$configKey];
}
return '';
}

/**
* Validate Cache Configuration
*
* @param $cacheConfig
* @return bool
*/
private function isCacheConfigValid($cacheConfig): bool
{
if ($this->getCacheConfigValue($cacheConfig, 'server')
&& $this->getCacheConfigValue($cacheConfig, 'port')
&& $this->getCacheConfigValue($cacheConfig, 'database')
) {
return true;
}
return false;
}

/**
* @param string $host
* @param int $port
Expand Down