Remove trailing whitespace

This commit is contained in:
Kijin Sung 2023-01-17 20:57:44 +09:00
parent 3b0030e82b
commit a9f72a5cd2
81 changed files with 2455 additions and 2455 deletions

View file

@ -13,18 +13,18 @@ class SQLite implements \Rhymix\Framework\Drivers\CacheInterface
* Set this flag to false to disable cache prefixes.
*/
public $prefix = false;
/**
* The singleton instance is stored here.
*/
protected static $_instance = null;
/**
* The database handle and prepared statements are stored here.
*/
protected $_dbh = null;
protected $_ps = array();
/**
* Direct invocation of the constructor is not permitted.
*/
@ -35,7 +35,7 @@ class SQLite implements \Rhymix\Framework\Drivers\CacheInterface
{
Storage::createDirectory($dir);
}
$key = substr(hash_hmac('sha256', $dir, config('crypto.authentication_key')), 0, 32);
$filename = "$dir/$key.db";
if (Storage::exists($filename))
@ -51,10 +51,10 @@ class SQLite implements \Rhymix\Framework\Drivers\CacheInterface
}
}
}
/**
* Connect to an SQLite3 database.
*
*
* @param string $filename
* @return void
*/
@ -65,10 +65,10 @@ class SQLite implements \Rhymix\Framework\Drivers\CacheInterface
$this->_dbh->exec('PRAGMA journal_mode = MEMORY');
$this->_dbh->exec('PRAGMA synchronous = OFF');
}
/**
* Create a new instance of the current cache driver, using the given settings.
*
*
* @param array $config
* @return void
*/
@ -80,24 +80,24 @@ class SQLite implements \Rhymix\Framework\Drivers\CacheInterface
}
return self::$_instance;
}
/**
* Check if the current cache driver is supported on this server.
*
*
* This method returns true on success and false on failure.
*
*
* @return bool
*/
public static function isSupported()
{
return class_exists('\\SQLite3', false) && config('crypto.authentication_key') !== null && stripos(\PHP_SAPI, 'win') === false;
}
/**
* Validate cache settings.
*
*
* This method returns true on success and false on failure.
*
*
* @param mixed $config
* @return bool
*/
@ -105,12 +105,12 @@ class SQLite implements \Rhymix\Framework\Drivers\CacheInterface
{
return true;
}
/**
* Get the value of a key.
*
*
* This method returns null if the key was not found.
*
*
* @param string $key
* @return mixed
*/
@ -122,14 +122,14 @@ class SQLite implements \Rhymix\Framework\Drivers\CacheInterface
{
return null;
}
$stmt->bindValue(':key', $key, \SQLITE3_TEXT);
$result = $stmt->execute();
if (!$result)
{
return null;
}
$row = $result->fetchArray(\SQLITE3_NUM);
if ($row)
{
@ -148,13 +148,13 @@ class SQLite implements \Rhymix\Framework\Drivers\CacheInterface
return null;
}
}
/**
* Set the value to a key.
*
*
* This method returns true on success and false on failure.
* $ttl is measured in seconds. If it is zero, the key should not expire.
*
*
* @param string $key
* @param mixed $value
* @param int $ttl
@ -169,19 +169,19 @@ class SQLite implements \Rhymix\Framework\Drivers\CacheInterface
{
return false;
}
$stmt->bindValue(':key', $key, \SQLITE3_TEXT);
$stmt->bindValue(':val', serialize($value), \SQLITE3_TEXT);
$stmt->bindValue(':exp', $ttl ? (time() + $ttl) : 0, \SQLITE3_INTEGER);
return $stmt->execute() ? true : false;
}
/**
* Delete a key.
*
*
* This method returns true on success and false on failure.
* If the key does not exist, it should return false.
*
*
* @param string $key
* @return bool
*/
@ -193,16 +193,16 @@ class SQLite implements \Rhymix\Framework\Drivers\CacheInterface
{
return false;
}
$stmt->bindValue(':key', $key, \SQLITE3_TEXT);
return $stmt->execute() ? true : false;
}
/**
* Check if a key exists.
*
*
* This method returns true on success and false on failure.
*
*
* @param string $key
* @return bool
*/
@ -214,7 +214,7 @@ class SQLite implements \Rhymix\Framework\Drivers\CacheInterface
{
return false;
}
$stmt->bindValue(':key', $key, \SQLITE3_TEXT);
$stmt->bindValue(':exp', time(), \SQLITE3_INTEGER);
$result = $stmt->execute();
@ -222,7 +222,7 @@ class SQLite implements \Rhymix\Framework\Drivers\CacheInterface
{
return false;
}
$row = $result->fetchArray(\SQLITE3_NUM);
if ($row)
{
@ -233,13 +233,13 @@ class SQLite implements \Rhymix\Framework\Drivers\CacheInterface
return false;
}
}
/**
* Increase the value of a key by $amount.
*
*
* If the key does not exist, this method assumes that the current value is zero.
* This method returns the new value.
*
*
* @param string $key
* @param int $amount
* @return int
@ -260,13 +260,13 @@ class SQLite implements \Rhymix\Framework\Drivers\CacheInterface
return false;
}
}
/**
* Decrease the value of a key by $amount.
*
*
* If the key does not exist, this method assumes that the current value is zero.
* This method returns the new value.
*
*
* @param string $key
* @param int $amount
* @return int
@ -275,12 +275,12 @@ class SQLite implements \Rhymix\Framework\Drivers\CacheInterface
{
return $this->incr($key, 0 - $amount);
}
/**
* Clear all keys from the cache.
*
*
* This method returns true on success and false on failure.
*
*
* @return bool
*/
public function clear()
@ -289,12 +289,12 @@ class SQLite implements \Rhymix\Framework\Drivers\CacheInterface
{
$this->_dbh->exec('DROP TABLE cache_' . $i);
}
for ($i = 0; $i < 32; $i++)
{
$this->_dbh->exec('CREATE TABLE cache_' . $i . ' (k TEXT PRIMARY KEY, v TEXT, exp INT)');
}
return true;
}
}