repository = $repository; $this->service = $service; $this->cache_service = $cache_service; } /** * The console command name. * * @var string */ protected $name = 'summit:json-generator'; /** * The name and signature of the console command. * * @var string */ protected $signature = 'summit:json-generator'; /** * The console command description. * * @var string */ protected $description = 'Regenerates All Summits Initial Json'; /** * Execute the console command. * * @return mixed */ public function handle() { $summits = $this->repository->getAvailables(); foreach($summits as $summit) { $this->info(sprintf("processing summit %s (%s)", $summit->getName(), $summit->getId())); $start = time(); $expand = 'schedule'; $data = SerializerRegistry::getInstance()->getSerializer($summit)->serialize($expand); if (is_null($data)) return; $end = time(); $delta = $end - $start; $this->info(sprintf("execution call %s seconds", $delta)); $current_time = time(); $key_current = sprintf('/api/v1/summits/%s.expand=%s', 'current', urlencode($expand)); $key_id = sprintf('/api/v1/summits/%s.expand=%s', $summit->getIdentifier(), urlencode($expand)); $cache_lifetime = intval(Config::get('cache_api_response.get_summit_response_lifetime', 600)); if ($summit->isActive()) { $this->cache_service->setSingleValue($key_current, gzdeflate(json_encode($data), 9), $cache_lifetime); $this->cache_service->setSingleValue($key_current . ".generated", $current_time, $cache_lifetime); } $this->cache_service->setSingleValue($key_id, gzdeflate(json_encode($data), 9), $cache_lifetime); $this->cache_service->setSingleValue($key_id . ".generated", $current_time, $cache_lifetime); $this->info(sprintf("regenerated cache for summit id %s", $summit->getIdentifier())); } } }