Cache_Eaccelerator
Kohana_Cache_Eaccelerator
Cache
Kohana_Cache

Class Contents

Class declared in MODPATH/cache/classes/cache/eaccelerator.php on line 3.

Constants

DEFAULT_EXPIRE
integer 3600

Properties

public static $default
string(4) "file"
public static $instances
array(0) 

Methods

protected __construct( )
Kohana_Cache_Eaccelerator

Source Code
protected function __construct(array $config)
{
	if ( ! extension_loaded('eaccelerator'))
	{
		throw new Kohana_Cache_Exception('PHP eAccelerator extension is not available.');
	}

	parent::__construct($config);
}

public delete( )
Kohana_Cache_Eaccelerator

Source Code
public function delete($id)
{
	return eaccelerator_rm($this->_sanitize_id($id));
}

public delete_all( )
Kohana_Cache_Eaccelerator

Source Code
public function delete_all()
{
	return eaccelerator_clean();
}

public get( )
Kohana_Cache_Eaccelerator

Source Code
public function get($id, $default = NULL)
{
	return (($data = eaccelerator_get($this->_sanitize_id($id))) === FALSE) ? $default : $data;
}

public set( )
Kohana_Cache_Eaccelerator

Source Code
public function set($id, $data, $lifetime = NULL)
{
	if ($lifetime === NULL)
	{
		$lifetime = time() + Arr::get($this->_config, 'default_expire', Cache::DEFAULT_EXPIRE);
	}

	return eaccelerator_put($this->_sanitize_id($id), $data, $lifetime);
}

public __clone( )
Kohana_Cache

Source Code
public function __clone()
{
	throw new Kohana_Cache_Exception('Cloning of Kohana_Cache objects is forbidden');
}

protected _sanitize_id( )
Kohana_Cache

Source Code
protected function _sanitize_id($id)
{
	// Change slashes and spaces to underscores
	return str_replace(array('/', '\\', ' '), '_', $id);
}

public static instance( )
Kohana_Cache

Source Code
public static function instance($group = NULL)
{
	// If there is no group supplied
	if ($group === NULL)
	{
		// Use the default setting
		$group = Cache::$default;
	}

	if (isset(Cache::$instances[$group]))
	{
		// Return the current group if initiated already
		return Cache::$instances[$group];
	}

	$config = Kohana::config('cache');

	if ( ! $config->offsetExists($group))
	{
		throw new Kohana_Cache_Exception('Failed to load Kohana Cache group: :group', array(':group' => $group));
	}

	$config = $config->get($group);

	// Create a new cache type instance
	$cache_class = 'Cache_'.ucfirst($config['driver']);
	Cache::$instances[$group] = new $cache_class($config);

	// Return the instance
	return Cache::$instances[$group];
}