public function getStatistics($user, $repository)
 {
     $id = $user . '/' . $repository;
     $statistics = $this->cache->get($id);
     if (!$statistics instanceof Statistics) {
         $statistics = $this->wrapped->getStatistics($user, $repository);
         $this->cache->set($id, $statistics);
     }
     return $statistics;
 }
 public function getStatistics($user, $repository)
 {
     // Fetch first, so that if an exception happens, we don't store the repository
     $statistics = $this->wrapped->getStatistics($user, $repository);
     // Store it
     $id = $user . '/' . $repository;
     if (!$this->repositories->get($id)) {
         $this->repositories->set($id, new Repository($id));
     }
     return $statistics;
 }
 private function update(Repository $repository, OutputInterface $output)
 {
     // Clear the cache
     $this->statisticsCache->set($repository->getName(), null);
     // Warmup the cache
     try {
         list($user, $repositoryName) = explode('/', $repository->getName(), 2);
         $this->statisticsProvider->getStatistics($user, $repositoryName);
     } catch (\Exception $e) {
         $output->writeln(sprintf('<error>Error while fetching statistics for %s</error>', $repository->getName()));
         $output->writeln(sprintf('<error>%s: %s</error>', get_class($e), $e->getMessage()));
     }
     // Mark the repository updated
     $repository->update();
     $this->repositoryStorage->set($repository->getName(), $repository);
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     foreach ($this->repositories as $id => $repository) {
         /** @var Repository $repository */
         $repository = $this->repositories->get($id);
         $slug = $repository->getName();
         $output->writeln(sprintf('Caching statistics for <info>%s</info>', $slug));
         list($user, $repo) = explode('/', $slug, 2);
         try {
             $this->statisticsProvider->getStatistics($user, $repo);
         } catch (\Exception $e) {
             $output->writeln(sprintf('<error>Error while fetching statistics for %s</error>', $slug));
             $output->writeln(sprintf('<error>%s: %s</error>', get_class($e), $e->getMessage()));
         }
     }
 }