CoreFiles by mySites.guru
eAccelerator.php83 lines, 2,039 bytes, from Joomla_1.5.3-Stable-Full_Package.zip
Raw History Compare with 1.5.2
md5
8eec6f0a54f6ad16cbc0058c8aeeb55b
sha1
d6012899f2daee027c996fa14428df55a91f694e
sha256
e76e4510a192951a5bdd11bdd72cd1223a72e2f6e2519db83a255baecff016a5
<?PHP
/**
 * patTemplate Template cache that stores data in the eAccelerator Cache
 *
 * $Id: eAccelerator.php 8287 2007-08-01 08:38:59Z eddieajau $
 *
 * @package		patTemplate
 * @subpackage	Caches
 * @author		Mike Valstar <[email protected]>
 */

// Check to ensure this file is within the rest of the framework
defined('JPATH_BASE') or die();

/**
 * patTemplate Template cache that stores data in the eAccelerator Cache
 *
 * If the lifetime is set to auto, the cache files will be kept until
 * you delete them manually.
 *
 * $Id: eAccelerator.php 8287 2007-08-01 08:38:59Z eddieajau $
 *
 * @package		patTemplate
 * @subpackage	Caches
 * @author		Mike Valstar <[email protected]>
 */
class patTemplate_TemplateCache_eAccelerator extends patTemplate_TemplateCache
{
	/**
	* parameters of the cache
	*
	* @access	private
	* @var		array
	*/
	var $_params = array( 'lifetime' => 'auto');

	/**
	* load template from cache
	*
	* @access   public
	* @param	string			cache key
	* @param	integer			modification time of original template
	* @return   array|boolean	either an array containing the templates or false cache could not be loaded
	*/
	function load( $key, $modTime = -1 )
	{
		if (!function_exists('eaccelerator_lock')) {
			return false;
		}
		$something = eaccelerator_get($key);
		if (is_null($something)){
			return false;
		}else{
			return unserialize($something);
		}
	}

	/**
	* write template to cache
	*
	* @access   public
	* @param	string		cache key
	* @param	array		templates to store
	* @return   boolean		true on success
	*/
	function write( $key, $templates )
	{
		if (!function_exists('eaccelerator_lock')) {
			return false;
		}

		eaccelerator_lock($key);
		if ($this->getParam( 'lifetime' ) == 'auto'){
			 eaccelerator_put($key, serialize( $templates ));
		}else{
			eaccelerator_put($key, serialize( $templates ), $this->getParam( 'lifetime' ) * 60);
		}
		 eaccelerator_unlock($key);

		 return true;
	}
}
?>

The same content is in 4 releases, Joomla 1.5.0 to 1.5.3. See them all, or every version of this file.