cache->get('api_products', function (ItemInterface $item) { $item->expiresAfter(3600); // 1 hour cache return $this->travelClient->getProducts(); }); return $this->json($products); } catch (InvalidArgumentException|ApiClientException $e) { return $this->json(['error' => $e->getMessage(), 'type' => 'api_error']); } } }