mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-17 23:13:15 +00:00
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
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2016 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Alchemy\Phrasea\Command\Setup;
|
||||
|
||||
use Alchemy\Phrasea\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Finder\Finder;
|
||||
|
||||
class SystemClearCacheCommand extends Command
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct('system:clear-cache');
|
||||
|
||||
$this->setDescription('Empties cache directories and cache-server data');
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function doExecute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$finder = new Finder();
|
||||
|
||||
$in = $this->container['cache.paths']->getArrayCopy();
|
||||
$finder
|
||||
->exclude('.git')
|
||||
->exclude('.svn')
|
||||
->in($in);
|
||||
|
||||
$this->container['filesystem']->remove($finder);
|
||||
|
||||
if ($this->container['phraseanet.configuration-tester']->isInstalled()) {
|
||||
$this->getService('phraseanet.cache-service')->flushAll();
|
||||
}
|
||||
|
||||
$output->write('Finished !', true);
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace Alchemy\Phrasea\Command\Setup;
|
||||
|
||||
use Alchemy\Phrasea\Cache\Factory;
|
||||
use Alchemy\Phrasea\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
class SystemClearSessionCacheCommand extends Command
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct('system:clear-session-cache');
|
||||
|
||||
$this->setDescription('Empties session cache in redis, ends sessions for all users');
|
||||
|
||||
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