feat(cache): update cache expiration times

- Update the cache expiration time for 'championsListAllCache' and 'championsRolesCache' to 8 hours.
- Update the cache expiration time for 'championShowCache{slug}' to 3 days.
- Update the cache expiration time for 'championSplashColorCache{slug}' to 6 months.
- Update the cache expiration time for 'championSkinShowCache{slug}' to 48 hours.
- Update the cache expiration time for 'championSkinSplashColorCache{slug}' to 120 hours.
This commit is contained in:
Rico van Zelst
2024-01-14 00:13:37 +01:00
parent e3cc331923
commit 5c6f13a072
2 changed files with 11 additions and 11 deletions

View File

@@ -17,9 +17,9 @@ class ChampionController extends Controller
{
$eightHoursInSeconds = 60 * 60 * 8;
$champions = Cache::remember('championsListAllCache', $eightHoursInSeconds, static fn () => Champion::orderBy('name')->get());
$champions = Cache::remember('championsListAllCache', $eightHoursInSeconds, static fn() => Champion::orderBy('name')->get());
$roles = Cache::remember('championsRolesCache', $eightHoursInSeconds, static fn () => ChampionRoles::orderBy('champion_name')->get());
$roles = Cache::remember('championsRolesCache', $eightHoursInSeconds, static fn() => ChampionRoles::orderBy('champion_name')->get());
return view('champions.index', ['champions' => $champions, 'roles' => $roles]);
}
@@ -45,15 +45,15 @@ class ChampionController extends Controller
*/
public function show(Champion $champion)
{
$eightHoursInSeconds = 60 * 60 * 8;
$dayInSeconds = 60 * 60 * 24;
$threeDaysInSeconds = 60 * 60 * 24 * 3;
$sixMonthsInSeconds = 60 * 60 * 24 * 30 * 6;
$champion = Cache::remember('championShowCache' . $champion->slug, $eightHoursInSeconds, static fn () => $champion->load('skins', 'lanes'));
$champion = Cache::remember('championShowCache' . $champion->slug, $threeDaysInSeconds, static fn() => $champion->load('skins', 'lanes'));
$splashColor = Cache::remember(
'championSplashColorCache' . $champion->slug,
$dayInSeconds,
static fn () => getAverageColorFromImageUrl($champion->getChampionImageAttribute())
$sixMonthsInSeconds,
static fn() => getAverageColorFromImageUrl($champion->getChampionImageAttribute())
);
$champion->splash_color = $splashColor;