public function clearCache(HttpCacheEvent $event)
 {
     switch (true) {
         case $event->getSubject() instanceof ContainerInterface:
             $this->cacheManager->invalidateRoute('swp_api_templates_list_containers');
             $this->cacheManager->invalidateRoute('swp_api_templates_get_container', ['id' => $event->getSubject()->getId()]);
             break;
     }
     try {
         $this->cacheManager->flush();
     } catch (ExceptionCollection $e) {
         $this->logger->error($e->getMessage());
     }
 }
 /**
  * Flush cache manager when console terminates or errors
  *
  * @throws ExceptionCollection If an exception occurs during flush.
  */
 public function onConsoleTerminate(ConsoleEvent $event)
 {
     $num = $this->cacheManager->flush();
     if ($num > 0 && OutputInterface::VERBOSITY_VERBOSE <= $event->getOutput()->getVerbosity()) {
         $event->getOutput()->writeln(sprintf('Sent %d invalidation request(s)', $num));
     }
 }
 public function __destruct()
 {
     $this->cacheManager->flush();
 }