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('Distributed cache matching prefix ' . $prefix . ' cleared');
} else {
$output->writeln('Distributed cache cleared');
}
return 0;
} else {
$output->writeln('Failed to clear cache');
return 1;
}
}
}