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

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

0

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

0

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

0

Sign in to participate in this thread!

Eventy

Your banner here too?

ircop ircop Joined 16 Sep 2014

Moderators

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

Your logo here?

Laravel.io

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

© 2024 Laravel.io - All rights reserved.