File tree 4 files changed +51
-1
lines changed
Filter options
4 files changed +51
-1
lines changed
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ declare (strict_types=1 );
4
+ /**
5
+ * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
6
+ * SPDX-License-Identifier: AGPL-3.0-or-later
7
+ */
8
+
9
+ namespace OC \Core \Command \Memcache ;
10
+
11
+ use OC \Core \Command \Base ;
12
+ use OCP \ICacheFactory ;
13
+ use Symfony \Component \Console \Input \InputInterface ;
14
+ use Symfony \Component \Console \Input \InputOption ;
15
+ use Symfony \Component \Console \Output \OutputInterface ;
16
+
17
+ class DistributedClear extends Base {
18
+ public function __construct (
19
+ protected ICacheFactory $ cacheFactory ,
20
+ ) {
21
+ parent ::__construct ();
22
+ }
23
+
24
+ protected function configure (): void {
25
+ $ this
26
+ ->setName ('memcache:distributed:clear ' )
27
+ ->setDescription ('Clear values from the distributed memcache ' )
28
+ ->addOption ('prefix ' , null , InputOption::VALUE_REQUIRED , 'Only remove keys matching the prefix ' );
29
+ parent ::configure ();
30
+ }
31
+
32
+ protected function execute (InputInterface $ input , OutputInterface $ output ): int {
33
+ $ cache = $ this ->cacheFactory ->createDistributed ();
34
+ $ prefix = $ input ->getOption ('prefix ' );
35
+ if ($ cache ->clear ($ prefix )) {
36
+ if ($ prefix ) {
37
+ $ output ->writeln ('Distributed cache matching prefix ' . $ prefix . ' cleared</info> ' );
38
+ } else {
39
+ $ output ->writeln ('Distributed cache cleared</info> ' );
40
+ }
41
+ return 0 ;
42
+ } else {
43
+ $ output ->writeln ('<error>Failed to clear cache</error> ' );
44
+ return 1 ;
45
+ }
46
+ }
47
+ }
Original file line number Diff line number Diff line change 68
68
use OC \Core \Command \Maintenance \RepairShareOwnership ;
69
69
use OC \Core \Command \Maintenance \UpdateHtaccess ;
70
70
use OC \Core \Command \Maintenance \UpdateTheme ;
71
- use OC \Core \Command \Memcache \RedisCommand ;
71
+ use OC \Core \Command \Memcache \DistributedClear ;
72
72
use OC \Core \Command \Memcache \DistributedDelete ;
73
73
use OC \Core \Command \Memcache \DistributedGet ;
74
74
use OC \Core \Command \Memcache \DistributedSet ;
247
247
$ application ->add (Server::get (Statistics::class));
248
248
249
249
$ application ->add (Server::get (RedisCommand::class));
250
+ $ application ->add (Server::get (DistributedClear::class));
250
251
$ application ->add (Server::get (DistributedDelete::class));
251
252
$ application ->add (Server::get (DistributedGet::class));
252
253
$ application ->add (Server::get (DistributedSet::class));
Original file line number Diff line number Diff line change 1287
1287
'OC \\Core \\Command \\Maintenance \\RepairShareOwnership ' => $ baseDir . '/core/Command/Maintenance/RepairShareOwnership.php ' ,
1288
1288
'OC \\Core \\Command \\Maintenance \\UpdateHtaccess ' => $ baseDir . '/core/Command/Maintenance/UpdateHtaccess.php ' ,
1289
1289
'OC \\Core \\Command \\Maintenance \\UpdateTheme ' => $ baseDir . '/core/Command/Maintenance/UpdateTheme.php ' ,
1290
+ 'OC \\Core \\Command \\Memcache \\DistributedClear ' => $ baseDir . '/core/Command/Memcache/DistributedClear.php ' ,
1290
1291
'OC \\Core \\Command \\Memcache \\DistributedDelete ' => $ baseDir . '/core/Command/Memcache/DistributedDelete.php ' ,
1291
1292
'OC \\Core \\Command \\Memcache \\DistributedGet ' => $ baseDir . '/core/Command/Memcache/DistributedGet.php ' ,
1292
1293
'OC \\Core \\Command \\Memcache \\DistributedSet ' => $ baseDir . '/core/Command/Memcache/DistributedSet.php ' ,
Original file line number Diff line number Diff line change @@ -1328,6 +1328,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
1328
1328
'OC \\Core \\Command \\Maintenance \\RepairShareOwnership ' => __DIR__ . '/../../.. ' . '/core/Command/Maintenance/RepairShareOwnership.php ' ,
1329
1329
'OC \\Core \\Command \\Maintenance \\UpdateHtaccess ' => __DIR__ . '/../../.. ' . '/core/Command/Maintenance/UpdateHtaccess.php ' ,
1330
1330
'OC \\Core \\Command \\Maintenance \\UpdateTheme ' => __DIR__ . '/../../.. ' . '/core/Command/Maintenance/UpdateTheme.php ' ,
1331
+ 'OC \\Core \\Command \\Memcache \\DistributedClear ' => __DIR__ . '/../../.. ' . '/core/Command/Memcache/DistributedClear.php ' ,
1331
1332
'OC \\Core \\Command \\Memcache \\DistributedDelete ' => __DIR__ . '/../../.. ' . '/core/Command/Memcache/DistributedDelete.php ' ,
1332
1333
'OC \\Core \\Command \\Memcache \\DistributedGet ' => __DIR__ . '/../../.. ' . '/core/Command/Memcache/DistributedGet.php ' ,
1333
1334
'OC \\Core \\Command \\Memcache \\DistributedSet ' => __DIR__ . '/../../.. ' . '/core/Command/Memcache/DistributedSet.php ' ,
You can’t perform that action at this time.
0 commit comments