Reduce queries on home page by eager loading into cache

This commit is contained in:
2026-05-24 22:15:16 +02:00
parent bb53e06c69
commit a6fe34a0d1

View File

@@ -128,7 +128,7 @@ class CacheHelper
public static function getLatestComments() public static function getLatestComments()
{ {
return Cache::remember('latest_comments', now()->addMinutes(60), function () { return Cache::remember('latest_comments', now()->addMinutes(60), function () {
return Comment::latest()->take(10)->get(); return Comment::with('user')->latest()->take(10)->get();
}); });
} }
} }