Cache config

This commit is contained in:
Daniel Brendel
2024-04-05 22:33:43 +02:00
parent 3ffc0d46f1
commit f13e7fff35
2 changed files with 11 additions and 6 deletions

6
app/config/cache.php Normal file
View File

@ -0,0 +1,6 @@
<?php
return [
'driver' => env('CACHE_DRIVER', null),
'duration' => env('CACHE_DURATION', 123)
];

View File

@ -13,14 +13,13 @@ class SteamCache {
*/ */
public static function cachedSteamApp($appid, $lang) public static function cachedSteamApp($appid, $lang)
{ {
$cache_driver = env('CACHE_DRIVER', null); $cache = config('cache');
$cache_duration = env('CACHE_DURATION', 123);
if ($cache_driver === 'db') { if ($cache->driver === 'db') {
return json_decode(CacheModel::remember('steam_app_' . $appid . '_' . $lang, $cache_duration, function() use ($appid, $lang) { return json_decode(CacheModel::remember('steam_app_' . $appid . '_' . $lang, $cache->duration, function() use ($appid, $lang) {
return json_encode(SteamApp::querySteamData($appid, $lang)); return json_encode(SteamApp::querySteamData($appid, $lang));
})); }));
} else if ($cache_driver === 'redis') { } else if ($cache->driver === 'redis') {
throw new \Exception('Not implemented yet.'); throw new \Exception('Not implemented yet.');
} else { } else {
return SteamApp::querySteamData($appid, $lang); return SteamApp::querySteamData($appid, $lang);