mirror of
https://github.com/sp-tarkov/forge.git
synced 2025-02-12 20:20: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 Illuminate\Contracts\View\View;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\View\Component;
|
||||
|
||||
class HomepageMods extends Component
|
||||
@ -37,16 +38,18 @@ class HomepageMods extends Component
|
||||
*/
|
||||
private function fetchFeaturedMods(): Collection
|
||||
{
|
||||
return Mod::whereFeatured(true)
|
||||
->with([
|
||||
'latestVersion',
|
||||
'latestVersion.latestSptVersion',
|
||||
'users:id,name',
|
||||
'license:id,name,link',
|
||||
])
|
||||
->inRandomOrder()
|
||||
->limit(6)
|
||||
->get();
|
||||
return Cache::flexible('homepage-featured-mods', [5, 10], function () {
|
||||
return Mod::whereFeatured(true)
|
||||
->with([
|
||||
'latestVersion',
|
||||
'latestVersion.latestSptVersion',
|
||||
'users:id,name',
|
||||
'license:id,name,link',
|
||||
])
|
||||
->inRandomOrder()
|
||||
->limit(6)
|
||||
->get();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@ -56,15 +59,17 @@ class HomepageMods extends Component
|
||||
*/
|
||||
private function fetchLatestMods(): Collection
|
||||
{
|
||||
return Mod::orderByDesc('created_at')
|
||||
->with([
|
||||
'latestVersion',
|
||||
'latestVersion.latestSptVersion',
|
||||
'users:id,name',
|
||||
'license:id,name,link',
|
||||
])
|
||||
->limit(6)
|
||||
->get();
|
||||
return Cache::flexible('homepage-latest-mods', [5, 10], function () {
|
||||
return Mod::orderByDesc('created_at')
|
||||
->with([
|
||||
'latestVersion',
|
||||
'latestVersion.latestSptVersion',
|
||||
'users:id,name',
|
||||
'license:id,name,link',
|
||||
])
|
||||
->limit(6)
|
||||
->get();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@ -74,14 +79,16 @@ class HomepageMods extends Component
|
||||
*/
|
||||
private function fetchUpdatedMods(): Collection
|
||||
{
|
||||
return Mod::orderByDesc('updated_at')
|
||||
->with([
|
||||
'latestUpdatedVersion',
|
||||
'latestUpdatedVersion.latestSptVersion',
|
||||
'users:id,name',
|
||||
'license:id,name,link',
|
||||
])
|
||||
->limit(6)
|
||||
->get();
|
||||
return Cache::flexible('homepage-updated-mods', [5, 10], function () {
|
||||
return Mod::orderByDesc('updated_at')
|
||||
->with([
|
||||
'latestUpdatedVersion',
|
||||
'latestUpdatedVersion.latestSptVersion',
|
||||
'users:id,name',
|
||||
'license:id,name,link',
|
||||
])
|
||||
->limit(6)
|
||||
->get();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user