. */ namespace Doctrine\ORM\Tools\Console\Command\ClearCache; use Symfony\Component\Console\Input\InputArgument, Symfony\Component\Console\Input\InputOption, Symfony\Component\Console; /** * Command to clear the query cache of the various cache drivers. * * @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @link www.doctrine-project.org * @since 2.0 * @version $Revision$ * @author Benjamin Eberlei * @author Guilherme Blanco * @author Jonathan Wage * @author Roman Borschel */ class QueryCommand extends Console\Command\Command { /** * @see Console\Command\Command */ protected function configure() { $this ->setName('orm:clear-cache:query') ->setDescription('Clear all query cache of the various cache drivers.') ->setDefinition(array()) ->setHelp(<<getHelper('em')->getEntityManager(); $cacheDriver = $em->getConfiguration()->getQueryCacheImpl(); if ( ! $cacheDriver) { throw new \InvalidArgumentException('No Query cache driver is configured on given EntityManager.'); } if ($cacheDriver instanceof \Doctrine\Common\Cache\ApcCache) { throw new \LogicException("Cannot clear APC Cache from Console, its shared in the Webserver memory and not accessible from the CLI."); } $output->write('Clearing ALL Query cache entries' . PHP_EOL); $cacheIds = $cacheDriver->deleteAll(); if ($cacheIds) { foreach ($cacheIds as $cacheId) { $output->write(' - ' . $cacheId . PHP_EOL); } } else { $output->write('No entries to be deleted.' . PHP_EOL); } } }