<?
class Cache_Generic
{
	private $_cache=null;
	
	function __construct($type=null)
	{
		if (!$type) $type=LabConfig::$cfg['use_memcached']?"memcache":"file";
		switch($type)
		{
			case('file'):
				$class="Lab";
				include_once dirname(__FILE__)."/Lab.php";
			break;
			case('memcache'):
				$class="Memcache";
				include_once dirname(__FILE__)."/Memcache.php";
			break;
		}
		$this->_cache='Cache_'.$class;
	}
	
	public function get($key)
	{
		return call_user_func(array($this->_cache, 'i'))->get($key);
	}
	
	public function set($key, $data, $time)
	{
		return call_user_func(array($this->_cache, 'i'))->set($key, $data, $time);
	}
	
	public function remove($key)
	{
		return call_user_func(array($this->_cache, 'i'))->remove($key);
	}
	
	public function clean()
	{
		return call_user_func(array($this->_cache, 'i'))->clean();
	}
}