GearmanCacheClearCommand.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. /**
  3. * Gearman Bundle for Symfony2
  4. *
  5. * @author Marc Morera <yuhu@mmoreram.com>
  6. * @since 2013
  7. */
  8. namespace Mmoreram\GearmanBundle\Command;
  9. use Symfony\Component\Console\Input\InputOption;
  10. use Symfony\Component\Console\Input\InputArgument;
  11. use Symfony\Component\Console\Input\InputInterface;
  12. use Symfony\Component\Console\Input\InputDefinition;
  13. use Mmoreram\GearmanBundle\Service\GearmanCache;
  14. use Symfony\Component\Console\Output\OutputInterface;
  15. use Mmoreram\GearmanBundle\Service\GearmanSettings;
  16. use Mmoreram\GearmanBundle\Module\GearmanBaseBundle;
  17. use Mmoreram\GearmanBundle\Service\GearmanCacheLoader;
  18. use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
  19. /**
  20. * Warm ups all cache data
  21. *
  22. * @author Marc Morera <yuhu@mmoreram.com>
  23. */
  24. class GearmanCacheClearCommand extends ContainerAwareCommand
  25. {
  26. /**
  27. * Console Command configuration
  28. */
  29. protected function configure()
  30. {
  31. parent::configure();
  32. $this ->setName('gearman:cache:clear')
  33. ->setAliases(array('cache:gearman:clear'))
  34. ->setDescription('Clears gearman cache data on current environment');
  35. }
  36. /**
  37. * Executes the current command.
  38. *
  39. * @param InputInterface $input An InputInterface instance
  40. * @param OutputInterface $output An OutputInterface instance
  41. *
  42. * @return integer 0 if everything went fine, or an error code
  43. *
  44. * @throws \LogicException When this abstract class is not implemented
  45. */
  46. protected function execute(InputInterface $input, OutputInterface $output)
  47. {
  48. $output->writeln('Clearing the cache for the ' . $this->getContainer()->get('kernel')->getEnvironment() . ' environment');
  49. $this
  50. ->getContainer()
  51. ->get('gearman.cache.wrapper')
  52. ->flush();
  53. }
  54. }