Support the ongoing development of →
Cache Database Eloquent
Last updated 1 year ago.

You can use middleware, and check if that query is on cache, if not you can add it. There is an example in Laracast.

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.

'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!


Your banner here too?

ircop ircop Joined 16 Sep 2014


We'd like to thank these amazing companies for supporting us

Your logo here?

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 - All rights reserved.