Files
Phraseanet/lib/classes/module/console/systemClearSessionCache.php
Aina Sitraka 71ef4bf1dd PHRAS-4011 : Moving cmd from console to setup - system:clear-cache system:clear-session (#4460)
* cmd clear cache in bin/setup

* Change maintenance state wording
2024-01-22 10:34:13 +01:00

36 lines
1.0 KiB
PHP

<?php
use Alchemy\Phrasea\Cache\Factory;
use Alchemy\Phrasea\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class module_console_systemClearSessionCache extends Command
{
public function __construct($name = null)
{
parent::__construct($name);
$this->setDescription('Empties session cache in redis <fg=yellow;>(Deprecated use bin/setup system:clear-session-cache instead)</>');
return $this;
}
protected function doExecute(InputInterface $input, OutputInterface $output)
{
/** @var Factory $cacheFactory */
$cacheFactory = $this->container['phraseanet.cache-factory'];
$cache = $cacheFactory->create('redis', ['host' => 'redis-session', 'port' => '6379']);
$flushOK = $cache->removeByPattern('PHPREDIS_SESSION*');
if ($flushOK) {
$output->writeln('session cache in redis successfully flushed!');
} else {
$output->writeln('flush failed!');
}
return 0;
}
}