Yes you can store the entire array in cache. It will be serialized and deserialized on request.
Documentation for more details :
So with cache, can i store this entire array?
Yes
// save the array using key-name of 'apidata' for 1 min
Cache::put( 'apidata', $ApiArray, 1 );
And then make it so if i run the request again it will go to the cache and fetch the data instead of actually sending the request?
Yes
// use cache if set
if ( Cache::has( 'apidata' ) ) {
// get the apidata from the cache
$ApiArray = Cache::get( 'apidata );
} else {
// get the api data, how ever you are doing it ...
$ApiArray = FetchAPI();
// save in cache
Cache::put( 'apidata', $ApiArray, 1 );
}
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community