Cache Database Queries in laravel

Laravel

Posted on 22 May 15 by Vickey
  434



if we have a common query which is fire on each page for example a i want to show sidebar to show subject list so i need same data on each page when i use query on each page it interact with database many time when we change our page.But in laravel we can cache our queries. by doing this no need to interact with database many times and the result of this the speed of our web application will increase.

$questions = Question::remember(60)->get();

this code create query cache for next one hour and there is no need to interact with database for next one hour.


If this post help you reduce time to develop, you can help me to maintain this website :)
www.000webhost.com