WEB: Fallback cache to files

This commit is contained in:
Mataniko committed 2020-10-02 08:53:30 -04:00
1 parent 5e943583f4
commit c0c4209efe
2 files changed
+10 -3

No files matched your search

+9 -3
View File
@@ -3,17 +3,23 @@ namespace ScummVM\Models;
use Phpfastcache\Helper\Psr16Adapter;
use Phpfastcache\Drivers\Redis\Config;
use Phpfastcache\Exceptions\PhpfastcacheDriverConnectException;
abstract class BasicModel
{
protected static $cache;
private $data;
public function __construct()
{
if (is_null(self::$cache)) {
$config = new Config(['database' => 8]);
self::$cache = new Psr16Adapter('redis', $config);
try {
$database = $_SERVER['HTTP_HOST'] === 'www.scummvm.org' ? 8 : 7;
$config = new Config(['database' => $database]);
self::$cache = new Psr16Adapter('redis', $config);
} catch (PhpfastcacheDriverConnectException $ex) {
// Fallback to files based cache
self::$cache = new Psr16Adapter('files');
}
}
}