You can use middleware, and check if that query is on cache, if not you can add it. There is an example in Laracast.
https://laracasts.com/lessons/caching-essentials
It's for laravel 4 but you can make it similar in laravel 5 with middleware
Thanks! It's an option.
But with middleware i can't set custom cache time and i don't want to cache ALL queries :)
But thanks anyway
It has been a while, but just in case someone runs across this question, there is a package that does just this. https://github.com/dwightwatson/rememberable
'Rememberable is an Eloquent trait for Laravel 5.0+ that brings back the remember() query functions from Laravel 4.2. This makes it super easy to cache your query results for an adjustable amount of time.'
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community