protected function execute(InputInterface $input, OutputInterface $output) { $cacheDir = $input->getArgument('cache'); $text = ""; if (file_exists($cacheDir)) { $gc = new GarbageCollector($cacheDir); if (file_exists($gc->getLockPath())) { unlink($gc->getLockPath()); } $text .= "<info>Garbage collection unlocked.</info>" . PHP_EOL; } else { $text .= "<error>Cache directory does not exist.</error>" . PHP_EOL; } $output->writeln($text); }
protected function execute(InputInterface $input, OutputInterface $output) { $cacheDir = $input->getArgument('cache'); $text = ""; $log = null; if ($input->getOption('log')) { $log = new Logger('InterventionRequest'); $log->pushHandler(new StreamHandler($input->getOption('log'), Logger::INFO)); } if (file_exists($cacheDir)) { $text .= "<info>Garbage collection started.</info>" . PHP_EOL; $gc = new GarbageCollector($cacheDir, $log); if ($input->getOption('ttl')) { $gc->setTtl($input->getOption('ttl')); } $gc->launch(); $text .= "<info>Garbage collection finished.</info>" . PHP_EOL; } else { $text .= "<error>Cache directory does not exist.</error>" . PHP_EOL; } $output->writeln($text); }
/** * Checks to see if the garbage collector should be initialized, and if it should, initializes it. * * @return void */ private function initializeGarbageCollection() { if ($this->garbageCollectionShouldRun()) { $garbageCollector = new GarbageCollector($this->cachePath, $this->logger); $garbageCollector->setTtl($this->ttl); $garbageCollector->launch(); } }