public static function Factory($p_engineName, $p_path = null)
{
if (is_null($p_path)) {
$path = dirname(__FILE__);
} else {
$path = $p_path;
}
$filePath = "{$path}/CacheEngine_{$p_engineName}.php";
if (!file_exists($filePath)) {
throw new InvalidCacheEngine($p_engineName);
}
require_once $filePath;
$className = "CacheEngine_{$p_engineName}";
if (!class_exists($className)) {
throw new InvalidCacheEngine($p_engineName);
}
$cacheObj = new $className();
if ($cacheObj->isSupported()) {
return $cacheObj;
}
return null;
}
/** * Returns true if the given cache engine was supported * * @param $p_cacheEngine * @return boolean * TRUE on success, FALSE on failure */ public static function IsSupported($p_cacheEngine = null) { if (empty($p_cacheEngine)) { return false; } try { if ($cacheEngine = CacheEngine::Factory($p_cacheEngine)) { return true; } else { return false; } } catch (InvalidCacheEngine $ex) { return false; } }