How to store all record in laravel5 CacheBy Hardik Savani | February 11, 2016 | | 850 Viewer | Category : Laravel
Share this post:
if you are work with large application which depend on large query and required large number of record at that time your application performence littel bit down. that problem overcome with laravel Cache functionality.
Laravel Cache provide to you store your large query in cache so your application performence improve.
first of all you must write
Here is an example using Laravel’s Fluent Query Builder:
$users = DB::table('order')
Of course, we can do the same thing using laravel Eloquent:
$users = Order::orderBy('price', 'desc')
But, it's work fine with very simple database query
if you have work with more complex database query you need to use cache this way.
1.)Cache all records.
$orderTable = Cache::remember('orderTable', 60, function()
"SOME COMPLEX JOINS ETC.."
Here 'orderTable' is a cache variable you can use this when you get all records from the cache like that,
2.)Get records from Cache
$data = Cache::get('orderTable');
3.)remove Cache records from the Cache memory. it must be required when you insert new record other wise you want to update any records.
- PHP - How to convert HTML file to PDF using Dompdf library?
- Laravel 5 json response from controller example
- GROUP_CONCAT with different SEPARATOR in laravel Example
- CRUD (Create Read Update Delete) Example in Laravel 5.2 from Scratch
- How to solve 'There are no commands defined in the "cashier" namespace' in Laravel 5
- How to create a text file for JSON and file download in Laravel 5?
- Laravel 5 export to pdf using maatwebsite example
- PHP Image upload without refreshing page using jquery example