@Wojtek-R how is that different from what I posted earlier (inlining the json method call aside)? Also, make sure you're passing $url into the Closure scope
@tykus that is literally all I've changed, $url is just to show what I am trying to do, in my code it is just a hardcoded url string (not a passed in variable).
just a heads up using this strategy. There maybe cases where the result of the request is incorrect/incomplete in some way BUT doesn't break AND then the cache could be unwanted. In those cases have a way to clear the cache. For example, I have service that sometimes returns empty results but all status codes are valid.
@webrobert good insight, thanks, is there some simple way to check if the request data is incomplete? The json data that I am getting is variable - it changes.
@Wojtek-R like I said, I've had apis that just return empty. So you're fooled into thinking that there aren't results. It's one of those silly things that you don't realize until your troubleshooting why you have a whole string of failed/incomplete somethings. It all depends on the api provider. Just be mindful that however that request comes back is how it is cached. Your system has to be smart enough (your logic) to dump the cache if it thinks there is an issue. And it could all be mute for what you are building. It's just one of those clever pieces of code that merits a warning.