Vergleich inc/cachehandlers/disk.php - 1.8.0 - 1.8.26

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 11Zeile 11
/**
* Disk Cache Handler
*/

/**
* Disk Cache Handler
*/

class diskCacheHandler

class diskCacheHandler implements CacheHandlerInterface

{
/**
* Connect and initialize this handler.
*
* @return boolean True if successful, false on failure
*/

{
/**
* Connect and initialize this handler.
*
* @return boolean True if successful, false on failure
*/

	function connect($silent=false)

	function connect()

	{
if(!@is_writable(MYBB_ROOT."cache"))
{

	{
if(!@is_writable(MYBB_ROOT."cache"))
{

Zeile 31Zeile 31
	/**
* Retrieve an item from the cache.
*

	/**
* Retrieve an item from the cache.
*

	 * @param string The name of the cache
* @param boolean True if we should do a hard refresh

	 * @param string $name The name of the cache


	 * @return mixed Cache data if successful, false if failure
*/

	 * @return mixed Cache data if successful, false if failure
*/


function fetch($name, $hard_refresh=false)

	function fetch($name)


	{
if(!@file_exists(MYBB_ROOT."/cache/{$name}.php"))

	{
if(!@file_exists(MYBB_ROOT."/cache/{$name}.php"))

		{
return false;
}

if(!isset($this->cache[$name]) || $hard_refresh == true)
{
@include(MYBB_ROOT."/cache/{$name}.php");
}
else
{
@include_once(MYBB_ROOT."/cache/{$name}.php");
}

		{
return false;
}

@include(MYBB_ROOT."/cache/{$name}.php");









// Return data
return $$name;


// Return data
return $$name;

	}

/**

	}

/**

	 * Write an item to the cache.
*

	 * Write an item to the cache.
*

	 * @param string The name of the cache
* @param mixed The data to write to the cache item

	 * @param string $name The name of the cache
* @param mixed $contents The data to write to the cache item

	 * @return boolean True on success, false on failure
*/
function put($name, $contents)

	 * @return boolean True on success, false on failure
*/
function put($name, $contents)

	{

	{

		global $mybb;
if(!is_writable(MYBB_ROOT."cache"))
{

		global $mybb;
if(!is_writable(MYBB_ROOT."cache"))
{

Zeile 74Zeile 65

$cache_file = fopen(MYBB_ROOT."cache/{$name}.php", "w") or $mybb->trigger_generic_error("cache_no_write");
flock($cache_file, LOCK_EX);


$cache_file = fopen(MYBB_ROOT."cache/{$name}.php", "w") or $mybb->trigger_generic_error("cache_no_write");
flock($cache_file, LOCK_EX);

		$cache_contents = "<?php\n\n/** MyBB Generated Cache - Do Not Alter\n * Cache Name: $name\n * Generated: ".gmdate("r")."\n*/\n\n";

		$cache_contents = "<?php\ndeclare(encoding='UTF-8');\n\n/** MyBB Generated Cache - Do Not Alter\n * Cache Name: $name\n * Generated: ".gmdate("r")."\n*/\n\n";

		$cache_contents .= "\$$name = ".var_export($contents, true).";\n\n?>";
fwrite($cache_file, $cache_contents);
flock($cache_file, LOCK_UN);
fclose($cache_file);

return true;

		$cache_contents .= "\$$name = ".var_export($contents, true).";\n\n?>";
fwrite($cache_file, $cache_contents);
flock($cache_file, LOCK_UN);
fclose($cache_file);

return true;

	}

/**

	}

/**

	 * Delete a cache
*

	 * Delete a cache
*

	 * @param string The name of the cache

	 * @param string $name The name of the cache

	 * @return boolean True on success, false on failure
*/
function delete($name)

	 * @return boolean True on success, false on failure
*/
function delete($name)

Zeile 96Zeile 87

/**
* Disconnect from the cache


/**
* Disconnect from the cache

 
	 *
* @return bool

	 */
function disconnect()
{

	 */
function disconnect()
{

Zeile 105Zeile 98
	/**
* Select the size of the disk cache
*

	/**
* Select the size of the disk cache
*

	 * @param string The name of the cache

	 * @param string $name The name of the cache

	 * @return integer the size of the disk cache
*/
function size_of($name='')

	 * @return integer the size of the disk cache
*/
function size_of($name='')