2525 */
2626namespace OCA \Settings \SetupChecks ;
2727
28+ use OCP \ICacheFactory ;
2829use OCP \IConfig ;
2930use OCP \IL10N ;
3031use OCP \IURLGenerator ;
@@ -36,6 +37,7 @@ public function __construct(
3637 private IL10N $ l10n ,
3738 private IConfig $ config ,
3839 private IURLGenerator $ urlGenerator ,
40+ private ICacheFactory $ cacheFactory ,
3941 ) {
4042 }
4143
@@ -72,6 +74,41 @@ public function run(): SetupResult {
7274 $ this ->urlGenerator ->linkToDocs ('admin-performance ' )
7375 );
7476 }
77+
78+ if ($ this ->cacheFactory ->isLocalCacheAvailable ()) {
79+ $ random = random_bytes (64 );
80+ $ local = $ this ->cacheFactory ->createLocal ('setupcheck.local ' );
81+ try {
82+ $ local ->set ('test ' , $ random );
83+ $ local2 = $ this ->cacheFactory ->createLocal ('setupcheck.local ' );
84+ $ actual = $ local2 ->get ('test ' );
85+ $ local ->remove ('test ' );
86+ } catch (\Throwable ) {
87+ $ actual = null ;
88+ }
89+
90+ if ($ actual !== $ random ) {
91+ return SetupResult::error ($ this ->l10n ->t ('Failed to write and read a value from local cache. ' ));
92+ }
93+ }
94+
95+ if ($ this ->cacheFactory ->isAvailable ()) {
96+ $ random = random_bytes (64 );
97+ $ distributed = $ this ->cacheFactory ->createDistributed ('setupcheck ' );
98+ try {
99+ $ distributed ->set ('test ' , $ random );
100+ $ distributed2 = $ this ->cacheFactory ->createDistributed ('setupcheck ' );
101+ $ actual = $ distributed2 ->get ('test ' );
102+ $ distributed ->remove ('test ' );
103+ } catch (\Throwable ) {
104+ $ actual = null ;
105+ }
106+
107+ if ($ actual !== $ random ) {
108+ return SetupResult::error ($ this ->l10n ->t ('Failed to write and read a value from distributed cache. ' ));
109+ }
110+ }
111+
75112 return SetupResult::success ($ this ->l10n ->t ('Configured ' ));
76113 }
77114}
0 commit comments