Jaylen Jaylen - 1 year ago 210
PHP Question

How can I use remember() method in Laravel to cache the query using query builder?

I have an application that is written using Laravel 5.2.

In many cases I am using query builder to build my queries like so


How can I use the method
to cache the query generated from the query builder?

I tried to use
just before
but this is giving me an error

Call to undefined method Illuminate\Database\Query\Builder::remember()

Answer Source

you should do this

 $value = Cache::remember('users', 60, function()
     return DB::table('users')->get();
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download