mirror of
https://github.com/scummvm/scummvm-web.git
synced 2026-11-18 21:35:12 +00:00
WEB: Fallback cache to files
This commit is contained in:
1 parent
5e943583f4
commit
c0c4209efe
2 files changed
+10
-3
No files matched your search
@@ -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');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user