Skip to content

Commit

Permalink
fix(setupcheck): Make the Memcache setupcheck use the cache
Browse files Browse the repository at this point in the history
Signed-off-by: Joas Schilling <[email protected]>

[skip ci]
  • Loading branch information
nickvergessen authored and backportbot[bot] committed Dec 2, 2024
1 parent 0c32d38 commit 6506449
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions apps/settings/lib/SetupChecks/MemcacheConfigured.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public function __construct(
private IL10N $l10n,
private IConfig $config,
private IURLGenerator $urlGenerator,
private ICacheFactory $cacheFactory,
) {
}

Expand Down Expand Up @@ -55,6 +56,41 @@ public function run(): SetupResult {
$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'));
}
}

0 comments on commit 6506449

Please sign in to comment.