use Symfony\Contracts\Cache\ItemInterface;
$httpClient = ...
$issData = $cache->get(
'iss_location_data',
/**
* Anonymous function.
* Variables declared outside have to be `use`-d (`$httpClient`)
* Class properties can be called directly (`$this->` should work)
*/
function (ItemInterface $item) use ($httpClient): array {
// Time is in seconds
$item->expiresAfter(5);
$response = $httpClient->request('GET', 'https://api.wheretheiss.at/v1/satellites/25544');
return $response->toArray();
}
);