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); }