1
0
mirror of https://github.com/cp6/my-idlers.git synced 2024-11-16 23:42:32 +01:00

Added cache for all servers

Added cache for all servers
This commit is contained in:
cp6 2022-03-02 00:42:50 +11:00
parent 413aac5d2f
commit 2d832f0159

View File

@ -23,12 +23,16 @@ class ServerController extends Controller
public function index()
{
$servers = DB::table('servers as s')
->join('pricings as pr', 's.id', '=', 'pr.service_id')
->join('providers as p', 's.provider_id', '=', 'p.id')
->join('locations as l', 's.location_id', '=', 'l.id')
->join('os as o', 's.os_id', '=', 'o.id')
->get(['s.*', 'pr.currency', 'pr.price', 'pr.term', 'pr.as_usd', 'pr.next_due_date', 'p.name as provider_name', 'l.name as location', 'o.name as os_name']);
$servers = Cache::remember('all_servers', 1440, function () {
return DB::table('servers as s')
->join('pricings as pr', 's.id', '=', 'pr.service_id')
->join('providers as p', 's.provider_id', '=', 'p.id')
->join('locations as l', 's.location_id', '=', 'l.id')
->join('os as o', 's.os_id', '=', 'o.id')
->get(['s.*', 'pr.currency', 'pr.price', 'pr.term', 'pr.as_usd', 'pr.next_due_date', 'p.name as provider_name', 'l.name as location', 'o.name as os_name']);
});
return view('servers.index', compact(['servers']));
}
@ -165,6 +169,7 @@ class ServerController extends Controller
Cache::forget('services_count');//Main page services_count cache
Cache::forget('due_soon');//Main page due_soon cache
Cache::forget('recently_added');//Main page recently_added cache
Cache::forget('all_servers');//all servers cache
return redirect()->route('servers.index')
->with('success', 'Server Created Successfully.');
@ -304,6 +309,7 @@ class ServerController extends Controller
Cache::forget('services_count');//Main page services_count cache
Cache::forget('due_soon');//Main page due_soon cache
Cache::forget('recently_added');//Main page recently_added cache
Cache::forget('all_servers');//all servers cache
return redirect()->route('servers.index')
->with('success', 'Server Updated Successfully.');
@ -325,6 +331,7 @@ class ServerController extends Controller
Cache::forget('services_count');//Main page services_count cache
Cache::forget('due_soon');//Main page due_soon cache
Cache::forget('recently_added');//Main page recently_added cache
Cache::forget('all_servers');//all servers cache
return redirect()->route('servers.index')
->with('success', 'Server was deleted Successfully.');