From 131115fb6a5bee0a37bbcbb296f7ec88425b68d5 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Thu, 15 May 2025 16:00:40 +0200 Subject: [PATCH] feat: add command to delete memcache key Signed-off-by: Robin Appelman --- core/Command/Memcache/DistributedDelete.php | 43 +++++++++++++++++++++ core/register_command.php | 2 + lib/composer/composer/autoload_classmap.php | 1 + lib/composer/composer/autoload_static.php | 1 + 4 files changed, 47 insertions(+) create mode 100644 core/Command/Memcache/DistributedDelete.php diff --git a/core/Command/Memcache/DistributedDelete.php b/core/Command/Memcache/DistributedDelete.php new file mode 100644 index 00000000000..ae0855acb03 --- /dev/null +++ b/core/Command/Memcache/DistributedDelete.php @@ -0,0 +1,43 @@ +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('Distributed cache key ' . $key . ' deleted'); + return 0; + } else { + $output->writeln('Failed to delete cache key ' . $key . ''); + return 1; + } + } +} diff --git a/core/register_command.php b/core/register_command.php index 97522f2568e..0b902377fcc 100644 --- a/core/register_command.php +++ b/core/register_command.php @@ -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 { diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php index cfda77b0994..6ce38cc39fd 100644 --- a/lib/composer/composer/autoload_classmap.php +++ b/lib/composer/composer/autoload_classmap.php @@ -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', diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php index 17757774255..ea949e5a07a 100644 --- a/lib/composer/composer/autoload_static.php +++ b/lib/composer/composer/autoload_static.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',