RedisCommand.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. namespace StatsBundle\Command;
  3. use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
  4. use Symfony\Component\Console\Input\InputInterface;
  5. use Symfony\Component\Console\Output\OutputInterface;
  6. use RedisBundle\Services\RedisService;
  7. class RedisCommand extends ContainerAwareCommand
  8. {
  9. protected function configure()
  10. {
  11. $this
  12. ->setName('redis:test')
  13. ->setDescription('Test Redis')
  14. ->setHelp('This command allows test redis')
  15. ;
  16. }
  17. /**
  18. * @param InputInterface $input
  19. * @param OutputInterface $output
  20. */
  21. protected function execute(InputInterface $input, OutputInterface $output)
  22. {
  23. /* @var $statsDeviceManager DeviceManager */
  24. $redis = $this->getContainer()->get('redis');
  25. //$parameters = ['tcp://127.0.0.1:6379'];
  26. //$redis->setOptions($options);
  27. //$redis->setConnection($parameters);
  28. $value = $redis->getString('clave',true);
  29. $output->writeln($value);
  30. }
  31. }