mirror of
https://github.com/nextcloud/server.git
synced 2026-04-20 22:00:39 -04:00
feat: add command to delete memcache key
Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
parent
8689a4ad2a
commit
131115fb6a
4 changed files with 47 additions and 0 deletions
43
core/Command/Memcache/DistributedDelete.php
Normal file
43
core/Command/Memcache/DistributedDelete.php
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
<?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\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
class DistributedDelete extends Base {
|
||||
public function __construct(
|
||||
protected ICacheFactory $cacheFactory,
|
||||
) {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
protected function configure(): void {
|
||||
$this
|
||||
->setName('memcache:distributed:delete')
|
||||
->setDescription('Delete a value in the distributed memcache')
|
||||
->addArgument('key', InputArgument::REQUIRED, 'The key to delete');
|
||||
parent::configure();
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int {
|
||||
$cache = $this->cacheFactory->createDistributed();
|
||||
$key = $input->getArgument('key');
|
||||
if ($cache->remove($key)) {
|
||||
$output->writeln('<info>Distributed cache key <info>' . $key . '</info> deleted</info>');
|
||||
return 0;
|
||||
} else {
|
||||
$output->writeln('<error>Failed to delete cache key ' . $key . '</error>');
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -69,6 +69,7 @@ use OC\Core\Command\Maintenance\RepairShareOwnership;
|
|||
use OC\Core\Command\Maintenance\UpdateHtaccess;
|
||||
use OC\Core\Command\Maintenance\UpdateTheme;
|
||||
use OC\Core\Command\Memcache\RedisCommand;
|
||||
use OC\Core\Command\Memcache\DistributedDelete;
|
||||
use OC\Core\Command\Memcache\DistributedGet;
|
||||
use OC\Core\Command\Memcache\DistributedSet;
|
||||
use OC\Core\Command\Memcache\RedisCommand;
|
||||
|
|
@ -248,6 +249,7 @@ if ($config->getSystemValueBool('installed', false)) {
|
|||
$application->add(Server::get(Statistics::class));
|
||||
|
||||
$application->add(Server::get(RedisCommand::class));
|
||||
$application->add(Server::get(DistributedDelete::class));
|
||||
$application->add(Server::get(DistributedGet::class));
|
||||
$application->add(Server::get(DistributedSet::class));
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -1293,6 +1293,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\\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',
|
||||
'OC\\Core\\Command\\Memcache\\RedisCommand' => $baseDir . '/core/Command/Memcache/RedisCommand.php',
|
||||
|
|
|
|||
|
|
@ -1334,6 +1334,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\\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',
|
||||
'OC\\Core\\Command\\Memcache\\RedisCommand' => __DIR__ . '/../../..' . '/core/Command/Memcache/RedisCommand.php',
|
||||
|
|
|
|||
Loading…
Reference in a new issue