Laravel 5 Caching a Lists() Query Results

Example of how to cache a lists() database query. I also needed to add a users count to each element in the list so that was running a query for each user. This was way too expensive in terms of execution speed so I decided to add a 30 min cache and results were so much faster.

I put the code into this helper function inside my controller.

Then you can call it like this.

Sam Deering

Sam Deering is a web developer from England (currently living in Australia). In his spare time he enjoys coding, playing chess, reading and investing.

2 thoughts on “Laravel 5 Caching a Lists() Query Results

Leave a Reply

Your email address will not be published. Required fields are marked *