aboutsummaryrefslogtreecommitdiffstats
path: root/apps/settings/lib/SetupChecks/MemcacheConfigured.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/settings/lib/SetupChecks/MemcacheConfigured.php')
-rw-r--r--apps/settings/lib/SetupChecks/MemcacheConfigured.php40
1 files changed, 39 insertions, 1 deletions
diff --git a/apps/settings/lib/SetupChecks/MemcacheConfigured.php b/apps/settings/lib/SetupChecks/MemcacheConfigured.php
index 03cdc91cb5f..e3601d428bb 100644
--- a/apps/settings/lib/SetupChecks/MemcacheConfigured.php
+++ b/apps/settings/lib/SetupChecks/MemcacheConfigured.php
@@ -8,6 +8,8 @@ declare(strict_types=1);
*/
namespace OCA\Settings\SetupChecks;
+use OC\Memcache\Memcached;
+use OCP\ICacheFactory;
use OCP\IConfig;
use OCP\IL10N;
use OCP\IURLGenerator;
@@ -19,6 +21,7 @@ class MemcacheConfigured implements ISetupCheck {
private IL10N $l10n,
private IConfig $config,
private IURLGenerator $urlGenerator,
+ private ICacheFactory $cacheFactory,
) {
}
@@ -35,7 +38,7 @@ class MemcacheConfigured implements ISetupCheck {
$memcacheLockingClass = $this->config->getSystemValue('memcache.locking', null);
$memcacheLocalClass = $this->config->getSystemValue('memcache.local', null);
$caches = array_filter([$memcacheDistributedClass,$memcacheLockingClass,$memcacheLocalClass]);
- if (in_array(\OC\Memcache\Memcached::class, array_map(fn (string $class) => ltrim($class, '\\'), $caches))) {
+ if (in_array(Memcached::class, array_map(fn (string $class) => ltrim($class, '\\'), $caches))) {
// wrong PHP module is installed
if (extension_loaded('memcache') && !extension_loaded('memcached')) {
return SetupResult::warning(
@@ -55,6 +58,41 @@ class MemcacheConfigured implements ISetupCheck {
$this->urlGenerator->linkToDocs('admin-performance')
);
}
+
+ if ($this->cacheFactory->isLocalCacheAvailable()) {
+ $random = bin2hex(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 = bin2hex(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'));
}
}