mako\Cache


Description


Cache class.


Class methods


Toggle source

protected __construct()


Protected constructor since this is a static class.

Return value

NULL

protected function __construct()
{
	// Nothing here
}

Toggle source

public static instance($name = NULL)


Returns an instance of the requested cache configuration.


Parameters

Type Description
string (optional) Cache configuration name
Return value

mako\cache\Adapter

public static function instance($name = null)
{
	$config = Config::get('cache');
		
	$name = ($name === null) ? $config['default'] : $name;

	if(!isset(static::$instances[$name]))
	{	
		if(isset($config['configurations'][$name]) === false)
		{
			throw new RuntimeException(vsprintf("%s(): '%s' has not been defined in the cache configuration.", array(__METHOD__, $name)));
		}
		
		$class = '\mako\cache\\' . $config['configurations'][$name]['type'];
		
		static::$instances[$name] = new $class($config['configurations'][$name]);
	}

	return static::$instances[$name];
}

Toggle source

public static __callStatic($name, $arguments)


Magic shortcut to the default cache instance.


Parameters

Type Description
string Method name
array Method arguments
Return value

mixed

public static function __callStatic($name, $arguments)
{
	return call_user_func_array(array(static::instance(), $name), $arguments);
}