From 8db48acfa66e6d2fcaf25e2d7c3a01e5b53dbf04 Mon Sep 17 00:00:00 2001 From: Martin <31348196+Earl0fPudding@users.noreply.github.com> Date: Fri, 13 Feb 2026 16:25:09 +0100 Subject: [PATCH 1/4] Add memcache.customprefix to Cache.php Signed-off-by: Martin <31348196+Earl0fPudding@users.noreply.github.com> --- lib/private/Memcache/Cache.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/private/Memcache/Cache.php b/lib/private/Memcache/Cache.php index 48013e2fe6bda..360c2c8dae6f8 100644 --- a/lib/private/Memcache/Cache.php +++ b/lib/private/Memcache/Cache.php @@ -22,7 +22,7 @@ public function __construct( * @return string Prefix used for caching purposes */ public function getPrefix() { - return $this->prefix; + return \OC::$server->getConfig()->getSystemValueString('memcache.customprefix') . $this->prefix; } /** From 500bc069618dfdc356abb6c033565c7c586d7e96 Mon Sep 17 00:00:00 2001 From: Martin <31348196+Earl0fPudding@users.noreply.github.com> Date: Tue, 17 Feb 2026 17:19:18 +0100 Subject: [PATCH 2/4] Revert changes in Cache.php Signed-off-by: Martin <31348196+Earl0fPudding@users.noreply.github.com> --- lib/private/Memcache/Cache.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/private/Memcache/Cache.php b/lib/private/Memcache/Cache.php index 360c2c8dae6f8..48013e2fe6bda 100644 --- a/lib/private/Memcache/Cache.php +++ b/lib/private/Memcache/Cache.php @@ -22,7 +22,7 @@ public function __construct( * @return string Prefix used for caching purposes */ public function getPrefix() { - return \OC::$server->getConfig()->getSystemValueString('memcache.customprefix') . $this->prefix; + return $this->prefix; } /** From b0b212e9d9c6da37376c47fa6926d07cc0e00dc0 Mon Sep 17 00:00:00 2001 From: Martin <31348196+Earl0fPudding@users.noreply.github.com> Date: Tue, 17 Feb 2026 17:42:34 +0100 Subject: [PATCH 3/4] Add ability to set custom cache prefix in Factory.php Signed-off-by: Martin <31348196+Earl0fPudding@users.noreply.github.com> --- lib/private/Memcache/Factory.php | 51 ++++++++++++++++++++------------ 1 file changed, 32 insertions(+), 19 deletions(-) diff --git a/lib/private/Memcache/Factory.php b/lib/private/Memcache/Factory.php index e083a357cbac9..50fadbc4c914d 100644 --- a/lib/private/Memcache/Factory.php +++ b/lib/private/Memcache/Factory.php @@ -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', ''); + // use the value of memcache.customprefix setting as prefix if set + if ($customprefix != '') { + $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; } @@ -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 != '') { + $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; } From ff93f531763a23de2e00e882bb372dd3c255f1d9 Mon Sep 17 00:00:00 2001 From: Martin <31348196+Earl0fPudding@users.noreply.github.com> Date: Wed, 18 Feb 2026 12:04:58 +0100 Subject: [PATCH 4/4] Change customprefix integration to prepend the prefix hash in Factory.php Signed-off-by: Martin <31348196+Earl0fPudding@users.noreply.github.com> --- lib/private/Memcache/Factory.php | 52 +++++++++++++------------------- 1 file changed, 21 insertions(+), 31 deletions(-) diff --git a/lib/private/Memcache/Factory.php b/lib/private/Memcache/Factory.php index 50fadbc4c914d..50da7b3d657c6 100644 --- a/lib/private/Memcache/Factory.php +++ b/lib/private/Memcache/Factory.php @@ -115,29 +115,24 @@ public function __construct( protected function getGlobalPrefix(): string { if ($this->globalPrefix === null) { $config = Server::get(SystemConfig::class); - $customprefix = $config->getValue('memcache.customprefix', ''); - // use the value of memcache.customprefix setting as prefix if set - if ($customprefix != '') { - $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); + $customprefix = $config->getValue('memcache_customprefix', ''); + $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 = $customprefix . ($customprefix != '' ? '/' : '') . hash('xxh128', $instanceid . $installedApps); } return $this->globalPrefix; } @@ -152,15 +147,10 @@ public function withServerVersionPrefix(\Closure $closure): void { $backupPrefix = $this->globalPrefix; $config = Server::get(SystemConfig::class); - $customprefix = $config->getValue('memcache.customprefix', ''); - // use the value of memcache.customprefix setting as prefix if set - if ($customprefix != '') { - $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())); - } + $customprefix = $config->getValue('memcache_customprefix', ''); + // Include instanceid in the prefix, in case multiple instances use the same cache (e.g. same FPM pool) + $instanceid = $config->getValue('instanceid'); + $this->globalPrefix = $customprefix . ($customprefix != '' ? '/' : '') . hash('xxh128', $instanceid . implode('.', $this->serverVersion->getVersion())); $closure($this); $this->globalPrefix = $backupPrefix; }