Skip to content
Closed
Changes from 3 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
51 changes: 32 additions & 19 deletions lib/private/Memcache/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,23 +115,29 @@ public function __construct(
protected function getGlobalPrefix(): string {
if ($this->globalPrefix === null) {
$config = Server::get(SystemConfig::class);
$maintenanceMode = $config->getValue('maintenance', false);
$versions = [];
if ($config->getValue('installed', false) && !$maintenanceMode) {
$appConfig = Server::get(IAppConfig::class);
// only get the enabled apps to clear the cache in case an app is enabled or disabled (e.g. clear routes)
$versions = $appConfig->getAppInstalledVersions(true);
ksort($versions);
} else {
// if not installed or in maintenance mode, we should distinguish between both states.
$versions['core:maintenance'] = $maintenanceMode ? '1' : '0';
$customprefix = $config->getValue('memcache.customprefix', '');
Comment thread
Earl0fPudding marked this conversation as resolved.
Outdated
// use the value of memcache.customprefix setting as prefix if set
if ($customprefix != '') {
Comment thread
Earl0fPudding marked this conversation as resolved.
Outdated
$this->globalPrefix = $customprefix;
} else {
$maintenanceMode = $config->getValue('maintenance', false);
$versions = [];
if ($config->getValue('installed', false) && !$maintenanceMode) {
$appConfig = Server::get(IAppConfig::class);
// only get the enabled apps to clear the cache in case an app is enabled or disabled (e.g. clear routes)
$versions = $appConfig->getAppInstalledVersions(true);
ksort($versions);
} else {
// if not installed or in maintenance mode, we should distinguish between both states.
$versions['core:maintenance'] = $maintenanceMode ? '1' : '0';
}
$versions['core'] = implode('.', $this->serverVersion->getVersion());

// Include instanceid in the prefix, in case multiple instances use the same cache (e.g. same FPM pool)
$instanceid = $config->getValue('instanceid');
$installedApps = implode(',', array_keys($versions)) . implode(',', array_values($versions));
$this->globalPrefix = hash('xxh128', $instanceid . $installedApps);
}
$versions['core'] = implode('.', $this->serverVersion->getVersion());

// Include instanceid in the prefix, in case multiple instances use the same cache (e.g. same FPM pool)
$instanceid = $config->getValue('instanceid');
$installedApps = implode(',', array_keys($versions)) . implode(',', array_values($versions));
$this->globalPrefix = hash('xxh128', $instanceid . $installedApps);
}
return $this->globalPrefix;
}
Expand All @@ -145,9 +151,16 @@ protected function getGlobalPrefix(): string {
public function withServerVersionPrefix(\Closure $closure): void {
$backupPrefix = $this->globalPrefix;

// Include instanceid in the prefix, in case multiple instances use the same cache (e.g. same FPM pool)
$instanceid = Server::get(SystemConfig::class)->getValue('instanceid');
$this->globalPrefix = hash('xxh128', $instanceid . implode('.', $this->serverVersion->getVersion()));
$config = Server::get(SystemConfig::class);
$customprefix = $config->getValue('memcache.customprefix', '');
// use the value of memcache.customprefix setting as prefix if set
if ($customprefix != '') {
Comment thread
Earl0fPudding marked this conversation as resolved.
Outdated
$this->globalPrefix = $customprefix . '_v' . implode('.', $this->serverVersion->getVersion());
} else {
// Include instanceid in the prefix, in case multiple instances use the same cache (e.g. same FPM pool)
$instanceid = Server::get(SystemConfig::class)->getValue('instanceid');
$this->globalPrefix = hash('xxh128', $instanceid . implode('.', $this->serverVersion->getVersion()));
}
$closure($this);
$this->globalPrefix = $backupPrefix;
}
Expand Down