mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-09 11:03:17 +00:00
PHRAS-3742 Admin flush session (#4131)
PHRAS-3742 : - flush session - command - redis remove by pattern - cmd - add log - clean table session
This commit is contained in:
35
lib/classes/module/console/systemClearSessionCache.php
Normal file
35
lib/classes/module/console/systemClearSessionCache.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?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');
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user