Level 51
Does this plugin help
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi Everyone, Im just in the process of testing laravel, and to test its capabilities, I have written a Guzzle Function this is called in a loop and this searched 1080 sensors for a curl response, and then displays the response, the only thing it running this kind of command is pretty hefty, so i was curious as to how i cache the Guzzle responses for a a certain time?
here's my code
public function streamData()
{
$streamNames = $this->streams()->pluck('mount_name');
$streamNames = substr($streamNames,1,-1);
$streamNames = str_replace('"', "", $streamNames);
$streamNames = str_replace(' ', "", $streamNames);
$url = 'http://myApi.com/api.php?mount=' . $streamNames . '&type=connected';
$client = new GuzzleHttpClient();
$apiRequest = $client->request('GET', $url);
$content = json_decode($apiRequest->getBody()->getContents());
return $content[0]; // process the response however makes sense
}
}
Please or to participate in this conversation.