diff --git a/composer.json b/composer.json index c131c648..2c588406 100644 --- a/composer.json +++ b/composer.json @@ -37,7 +37,8 @@ "mv images/*.png public_html/images", "rm -rf images", "composer install --no-dev", - "npm install --production" + "npm install --production", + "redis-cli -n 8 flushdb" ], "build-win": [ "if NOT EXIST public_html\\css mkdir public_html\\css", diff --git a/include/Models/BasicModel.php b/include/Models/BasicModel.php index 07439ba2..34908eb7 100644 --- a/include/Models/BasicModel.php +++ b/include/Models/BasicModel.php @@ -2,6 +2,7 @@ namespace ScummVM\Models; use Phpfastcache\Helper\Psr16Adapter; +use Phpfastcache\Drivers\Redis\Config; abstract class BasicModel { @@ -11,19 +12,26 @@ abstract class BasicModel public function __construct() { if (is_null(self::$cache)) { - self::$cache = new Psr16Adapter('redis'); + $config = new Config(['database' => 8]); + self::$cache = new Psr16Adapter('redis', $config); } } protected function saveToCache($data, $key = '') { - $cacheKey = str_replace("\\", "_", \get_called_class() . "_$key"); - self::$cache->set($cacheKey, $data, 900); + if ($key) { + $key = "_$key"; + } + $cacheKey = str_replace("\\", "_", \get_called_class() . $key); + self::$cache->set($cacheKey, $data, 3600); } protected function getFromCache($key = '') { - $cacheKey = str_replace("\\", "_", \get_called_class() . "_$key"); + if ($key) { + $key = "_$key"; + } + $cacheKey = str_replace("\\", "_", \get_called_class() . $key); $cachedData = self::$cache->get($cacheKey); return $cachedData; }