aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoas Schilling <213943+nickvergessen@users.noreply.github.com>2024-12-02 10:04:14 +0100
committerGitHub <noreply@github.com>2024-12-02 10:04:14 +0100
commit199515f9fec91b5deba3078290081d391e443b7c (patch)
treefbb40be6cbbe069b187077a7847c5fbfb71e69e8
parent6aa81137c8279b561d9635d575a92ff818199dca (diff)
parent1bcc381e28de06c9d67915606792eaa488ca7535 (diff)
downloadnextcloud-server-199515f9fec91b5deba3078290081d391e443b7c.tar.gz
nextcloud-server-199515f9fec91b5deba3078290081d391e443b7c.zip
Merge pull request #49588 from nextcloud/bugfix/noid/make-the-cache-check-use-it
fix(setupcheck): Make the Memcache setupcheck use the cache
-rw-r--r--apps/settings/lib/SetupChecks/MemcacheConfigured.php37
1 files changed, 37 insertions, 0 deletions
diff --git a/apps/settings/lib/SetupChecks/MemcacheConfigured.php b/apps/settings/lib/SetupChecks/MemcacheConfigured.php
index d42b0f67298..65151591fbf 100644
--- a/apps/settings/lib/SetupChecks/MemcacheConfigured.php
+++ b/apps/settings/lib/SetupChecks/MemcacheConfigured.php
@@ -9,6 +9,7 @@ declare(strict_types=1);
namespace OCA\Settings\SetupChecks;
use OC\Memcache\Memcached;
+use OCP\ICacheFactory;
use OCP\IConfig;
use OCP\IL10N;
use OCP\IURLGenerator;
@@ -20,6 +21,7 @@ class MemcacheConfigured implements ISetupCheck {
private IL10N $l10n,
private IConfig $config,
private IURLGenerator $urlGenerator,
+ private ICacheFactory $cacheFactory,
) {
}
@@ -56,6 +58,41 @@ class MemcacheConfigured implements ISetupCheck {
$this->urlGenerator->linkToDocs('admin-performance')
);
}
+
+ if ($this->cacheFactory->isLocalCacheAvailable()) {
+ $random = random_bytes(64);
+ $local = $this->cacheFactory->createLocal('setupcheck.local');
+ try {
+ $local->set('test', $random);
+ $local2 = $this->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 ($this->cacheFactory->isAvailable()) {
+ $random = random_bytes(64);
+ $distributed = $this->cacheFactory->createDistributed('setupcheck');
+ try {
+ $distributed->set('test', $random);
+ $distributed2 = $this->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'));
}
}