Jaylen Jaylen - 6 months ago 80
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()


you should do this

 $value = Cache::remember('users', 60, function()
     return DB::table('users')->get();