Skip to content

Commit

Permalink
cache ecology value
Browse files Browse the repository at this point in the history
  • Loading branch information
Gummibeer committed Aug 28, 2024
1 parent c51f304 commit ed53c05
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion app/Http/Controllers/HomeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
use App\Models\Sponsor;
use App\Models\Trustee;
use Astrotomic\Ecologi\Ecologi;
use Carbon\CarbonInterval;
use Illuminate\Support\Facades\Cache;
use Illuminate\View\View;

class HomeController
Expand Down Expand Up @@ -53,7 +55,11 @@ public function __invoke(Ecologi $ecologi): View
+ Application::pluck('contributor_stats')->map->sum()->sum(),
'stars' => Package::sum('github_stars')
+ Application::sum('github_stars'),
'trees' => $ecologi->reporting()->getTrees('astrotomic'),
'trees' => Cache::remember(
key: 'ecologi.reporting.trees',
ttl: CarbonInterval::day(),
callback: fn () => $ecologi->reporting()->getTrees('astrotomic')
),
],
'apps' => $apps,
'promos' => $promos,
Expand Down

0 comments on commit ed53c05

Please sign in to comment.