diff --git a/apps/settings/lib/SetupChecks/MemcacheConfigured.php b/apps/settings/lib/SetupChecks/MemcacheConfigured.php index d42b0f6729827..049f24ca3b33b 100644 --- a/apps/settings/lib/SetupChecks/MemcacheConfigured.php +++ b/apps/settings/lib/SetupChecks/MemcacheConfigured.php @@ -9,9 +9,11 @@ namespace OCA\Settings\SetupChecks; use OC\Memcache\Memcached; +use OCP\ICacheFactory; use OCP\IConfig; use OCP\IL10N; use OCP\IURLGenerator; +use OCP\Server; use OCP\SetupCheck\ISetupCheck; use OCP\SetupCheck\SetupResult; @@ -56,6 +58,42 @@ public function run(): SetupResult { $this->urlGenerator->linkToDocs('admin-performance') ); } + + $cacheFactory = Server::get(ICacheFactory::class); + if ($cacheFactory->isLocalCacheAvailable()) { + $random = random_bytes(64); + $local = $cacheFactory->createLocal('setupcheck.local'); + try { + $local->set('test', $random); + $local2 = $cacheFactory->createLocal('setupcheck.local'); + $actual = $local2->get('test'); + $local->remove('test'); + } catch (\Throwable) { + $actual = null; + } + + if ($actual !== $random) { + return SetupResult::error($this->l10n->t('Failed to write and read a value from local cache.')); + } + } + + if ($cacheFactory->isAvailable()) { + $random = random_bytes(64); + $distributed = $cacheFactory->createDistributed('setupcheck'); + try { + $distributed->set('test', $random); + $distributed2 = $cacheFactory->createDistributed('setupcheck'); + $actual = $distributed2->get('test'); + $distributed->remove('test'); + } catch (\Throwable) { + $actual = null; + } + + if ($actual !== $random) { + return SetupResult::error($this->l10n->t('Failed to write and read a value from distributed cache.')); + } + } + return SetupResult::success($this->l10n->t('Configured')); } }