mirror of
https://github.com/sp-tarkov/forge.git
synced 2025-02-13 04:30:41 -05:00
Homepage Query Caching
This commit is contained in:
parent
e1b406f75e
commit
7909f629c6
@ -5,6 +5,7 @@ namespace App\View\Components;
|
|||||||
use App\Models\Mod;
|
use App\Models\Mod;
|
||||||
use Illuminate\Contracts\View\View;
|
use Illuminate\Contracts\View\View;
|
||||||
use Illuminate\Database\Eloquent\Collection;
|
use Illuminate\Database\Eloquent\Collection;
|
||||||
|
use Illuminate\Support\Facades\Cache;
|
||||||
use Illuminate\View\Component;
|
use Illuminate\View\Component;
|
||||||
|
|
||||||
class HomepageMods extends Component
|
class HomepageMods extends Component
|
||||||
@ -37,16 +38,18 @@ class HomepageMods extends Component
|
|||||||
*/
|
*/
|
||||||
private function fetchFeaturedMods(): Collection
|
private function fetchFeaturedMods(): Collection
|
||||||
{
|
{
|
||||||
return Mod::whereFeatured(true)
|
return Cache::flexible('homepage-featured-mods', [5, 10], function () {
|
||||||
->with([
|
return Mod::whereFeatured(true)
|
||||||
'latestVersion',
|
->with([
|
||||||
'latestVersion.latestSptVersion',
|
'latestVersion',
|
||||||
'users:id,name',
|
'latestVersion.latestSptVersion',
|
||||||
'license:id,name,link',
|
'users:id,name',
|
||||||
])
|
'license:id,name,link',
|
||||||
->inRandomOrder()
|
])
|
||||||
->limit(6)
|
->inRandomOrder()
|
||||||
->get();
|
->limit(6)
|
||||||
|
->get();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -56,15 +59,17 @@ class HomepageMods extends Component
|
|||||||
*/
|
*/
|
||||||
private function fetchLatestMods(): Collection
|
private function fetchLatestMods(): Collection
|
||||||
{
|
{
|
||||||
return Mod::orderByDesc('created_at')
|
return Cache::flexible('homepage-latest-mods', [5, 10], function () {
|
||||||
->with([
|
return Mod::orderByDesc('created_at')
|
||||||
'latestVersion',
|
->with([
|
||||||
'latestVersion.latestSptVersion',
|
'latestVersion',
|
||||||
'users:id,name',
|
'latestVersion.latestSptVersion',
|
||||||
'license:id,name,link',
|
'users:id,name',
|
||||||
])
|
'license:id,name,link',
|
||||||
->limit(6)
|
])
|
||||||
->get();
|
->limit(6)
|
||||||
|
->get();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -74,14 +79,16 @@ class HomepageMods extends Component
|
|||||||
*/
|
*/
|
||||||
private function fetchUpdatedMods(): Collection
|
private function fetchUpdatedMods(): Collection
|
||||||
{
|
{
|
||||||
return Mod::orderByDesc('updated_at')
|
return Cache::flexible('homepage-updated-mods', [5, 10], function () {
|
||||||
->with([
|
return Mod::orderByDesc('updated_at')
|
||||||
'latestUpdatedVersion',
|
->with([
|
||||||
'latestUpdatedVersion.latestSptVersion',
|
'latestUpdatedVersion',
|
||||||
'users:id,name',
|
'latestUpdatedVersion.latestSptVersion',
|
||||||
'license:id,name,link',
|
'users:id,name',
|
||||||
])
|
'license:id,name,link',
|
||||||
->limit(6)
|
])
|
||||||
->get();
|
->limit(6)
|
||||||
|
->get();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user