mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-04-24 12:52:19 +09:00
Make all cache drivers singleton instances
This commit is contained in:
parent
9b71df6a01
commit
2227e0d278
10 changed files with 164 additions and 40 deletions
31
common/framework/drivers/cache/sqlite.php
vendored
31
common/framework/drivers/cache/sqlite.php
vendored
|
|
@ -14,6 +14,11 @@ class SQLite implements \Rhymix\Framework\Drivers\CacheInterface
|
|||
*/
|
||||
public $prefix = false;
|
||||
|
||||
/**
|
||||
* The singleton instance is stored here.
|
||||
*/
|
||||
protected static $_instance = null;
|
||||
|
||||
/**
|
||||
* The database handle and prepared statements are stored here.
|
||||
*/
|
||||
|
|
@ -21,12 +26,9 @@ class SQLite implements \Rhymix\Framework\Drivers\CacheInterface
|
|||
protected $_ps = array();
|
||||
|
||||
/**
|
||||
* Create a new instance of the current cache driver, using the given settings.
|
||||
*
|
||||
* @param array $config
|
||||
* @return void
|
||||
* Direct invocation of the constructor is not permitted.
|
||||
*/
|
||||
public function __construct(array $config)
|
||||
protected function __construct()
|
||||
{
|
||||
$dir = \RX_BASEDIR . 'files/cache/store';
|
||||
if (!Storage::isDirectory($dir))
|
||||
|
|
@ -63,6 +65,21 @@ class SQLite implements \Rhymix\Framework\Drivers\CacheInterface
|
|||
$this->_dbh->exec('PRAGMA synchronous = OFF');
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new instance of the current cache driver, using the given settings.
|
||||
*
|
||||
* @param array $config
|
||||
* @return void
|
||||
*/
|
||||
public static function getInstance(array $config)
|
||||
{
|
||||
if (self::$_instance === null)
|
||||
{
|
||||
self::$_instance = new self();
|
||||
}
|
||||
return self::$_instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the current cache driver is supported on this server.
|
||||
*
|
||||
|
|
@ -70,9 +87,9 @@ class SQLite implements \Rhymix\Framework\Drivers\CacheInterface
|
|||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isSupported()
|
||||
public static function isSupported()
|
||||
{
|
||||
return class_exists('\\SQLite3', false) && config('crypto.authentication_key');
|
||||
return class_exists('\\SQLite3', false) && config('crypto.authentication_key') !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue