Skip to content
Closed
Changes from 4 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
9 changes: 6 additions & 3 deletions lib/private/Memcache/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ public function __construct(
protected function getGlobalPrefix(): string {
if ($this->globalPrefix === null) {
$config = Server::get(SystemConfig::class);
$customprefix = $config->getValue('memcache_customprefix', '');
Comment thread
Earl0fPudding marked this conversation as resolved.
$maintenanceMode = $config->getValue('maintenance', false);
$versions = [];
if ($config->getValue('installed', false) && !$maintenanceMode) {
Expand All @@ -131,7 +132,7 @@ protected function getGlobalPrefix(): string {
// 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);
$this->globalPrefix = $customprefix . ($customprefix != '' ? '/' : '') . hash('xxh128', $instanceid . $installedApps);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$this->globalPrefix = $customprefix . ($customprefix != '' ? '/' : '') . hash('xxh128', $instanceid . $installedApps);
$this->globalPrefix = $customprefix . hash('xxh128', $instanceid . $installedApps);

I would prefer the above version to keep it simple.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

}
return $this->globalPrefix;
}
Expand All @@ -145,9 +146,11 @@ protected function getGlobalPrefix(): string {
public function withServerVersionPrefix(\Closure $closure): void {
$backupPrefix = $this->globalPrefix;

$config = Server::get(SystemConfig::class);
$customprefix = $config->getValue('memcache_customprefix', '');
// 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()));
$instanceid = $config->getValue('instanceid');
$this->globalPrefix = $customprefix . ($customprefix != '' ? '/' : '') . hash('xxh128', $instanceid . implode('.', $this->serverVersion->getVersion()));
$closure($this);
$this->globalPrefix = $backupPrefix;
}
Expand Down