mirror of
https://github.com/nextcloud/server.git
synced 2026-05-13 17:10:43 -04:00
feat: add command to clear memcache
Signed-off-by: Robin Appelman <robin@icewind.nl> [skip ci]
This commit is contained in:
parent
a8428cad01
commit
32e201e540
3 changed files with 49 additions and 0 deletions
47
core/Command/Memcache/DistributedClear.php
Normal file
47
core/Command/Memcache/DistributedClear.php
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
namespace OC\Core\Command\Memcache;
|
||||
|
||||
use OC\Core\Command\Base;
|
||||
use OCP\ICacheFactory;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
class DistributedClear extends Base {
|
||||
public function __construct(
|
||||
protected ICacheFactory $cacheFactory,
|
||||
) {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
protected function configure(): void {
|
||||
$this
|
||||
->setName('memcache:distributed:clear')
|
||||
->setDescription('Clear values from the distributed memcache')
|
||||
->addOption('prefix', null, InputOption::VALUE_REQUIRED, 'Only remove keys matching the prefix');
|
||||
parent::configure();
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int {
|
||||
$cache = $this->cacheFactory->createDistributed();
|
||||
$prefix = $input->getOption('prefix');
|
||||
if ($cache->clear($prefix)) {
|
||||
if ($prefix) {
|
||||
$output->writeln('<info>Distributed cache matching prefix ' . $prefix . ' cleared</info>');
|
||||
} else {
|
||||
$output->writeln('<info>Distributed cache cleared</info>');
|
||||
}
|
||||
return 0;
|
||||
} else {
|
||||
$output->writeln('<error>Failed to clear cache</error>');
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1284,6 +1284,7 @@ return array(
|
|||
'OC\\Core\\Command\\Maintenance\\RepairShareOwnership' => $baseDir . '/core/Command/Maintenance/RepairShareOwnership.php',
|
||||
'OC\\Core\\Command\\Maintenance\\UpdateHtaccess' => $baseDir . '/core/Command/Maintenance/UpdateHtaccess.php',
|
||||
'OC\\Core\\Command\\Maintenance\\UpdateTheme' => $baseDir . '/core/Command/Maintenance/UpdateTheme.php',
|
||||
'OC\\Core\\Command\\Memcache\\DistributedClear' => $baseDir . '/core/Command/Memcache/DistributedClear.php',
|
||||
'OC\\Core\\Command\\Memcache\\DistributedDelete' => $baseDir . '/core/Command/Memcache/DistributedDelete.php',
|
||||
'OC\\Core\\Command\\Memcache\\DistributedGet' => $baseDir . '/core/Command/Memcache/DistributedGet.php',
|
||||
'OC\\Core\\Command\\Memcache\\DistributedSet' => $baseDir . '/core/Command/Memcache/DistributedSet.php',
|
||||
|
|
|
|||
|
|
@ -1333,6 +1333,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
|
|||
'OC\\Core\\Command\\Maintenance\\RepairShareOwnership' => __DIR__ . '/../../..' . '/core/Command/Maintenance/RepairShareOwnership.php',
|
||||
'OC\\Core\\Command\\Maintenance\\UpdateHtaccess' => __DIR__ . '/../../..' . '/core/Command/Maintenance/UpdateHtaccess.php',
|
||||
'OC\\Core\\Command\\Maintenance\\UpdateTheme' => __DIR__ . '/../../..' . '/core/Command/Maintenance/UpdateTheme.php',
|
||||
'OC\\Core\\Command\\Memcache\\DistributedClear' => __DIR__ . '/../../..' . '/core/Command/Memcache/DistributedClear.php',
|
||||
'OC\\Core\\Command\\Memcache\\DistributedDelete' => __DIR__ . '/../../..' . '/core/Command/Memcache/DistributedDelete.php',
|
||||
'OC\\Core\\Command\\Memcache\\DistributedGet' => __DIR__ . '/../../..' . '/core/Command/Memcache/DistributedGet.php',
|
||||
'OC\\Core\\Command\\Memcache\\DistributedSet' => __DIR__ . '/../../..' . '/core/Command/Memcache/DistributedSet.php',
|
||||
|
|
|
|||
Loading…
Reference in a new issue