mirror of
https://github.com/scummvm/scummvm-web.git
synced 2026-11-18 21:35:12 +00:00
WEB: Increase cache duration and clear cache during site update
This commit is contained in:
1 parent
a757a3bc14
commit
6816cdab5a
2 files changed
+14
-5
No files matched your search
@@ -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;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user