/** * * @param string $cacheType * 缓存类型 * @throws cacheException * @return Ambigous <>|Ambigous <\fl\cache\icache> */ public static function getcacheobj($cacheType = null) { static $cacheMap = array(); if (\fl\base\core::isSae()) { $cacheType = 'sae'; } else { $s_cfg = \fl\cfg\cfg::getcfgobj('cache', 'ini'); $defaultType = $s_cfg->get('main', 'default'); $cacheType = $cacheType ? $cacheType : $defaultType; } if (isset($cacheMap[$cacheType]) && is_object($cacheMap[$cacheType])) { return $cacheMap[$cacheType]; } switch (strtolower($cacheType)) { case 'memcache': case 'memcached': $cacheMap[$cacheType] = new \fl\cache\memcache($s_cfg->get('memcache')); break; case 'apc': $cacheMap[$cacheType] = new \fl\cache\apc(array()); break; case 'dummy': $cacheMap[$cacheType] = new \fl\cache\dummy(array()); break; case 'file': $cacheMap[$cacheType] = new \fl\cache\file(array()); break; case 'sae': $cacheMap[$cacheType] = new \fl\cache\sae(array()); break; default: throw new \Exception("not support cache Type.", -100); } return $cacheMap[$cacheType]; }
public static final function getQueryerBuilder($dbcfg) { static $querybuilder = array(); if (isset($querybuilder[$dbcfg])) { return $querybuilder[$dbcfg]; } $s_cfg = \fl\cfg\cfg::getcfgobj('db/' . $dbcfg, 'ini'); switch (strtolower($s_cfg->get('main', 'type'))) { case 'mysql': $querybuilder[$dbcfg] = new mysql\QueryBuilder(new mysql\connect($dbcfg)); break; case 'sqlite': $querybuilder[$dbcfg] = new sqlite\QueryBuilder(new sqlite\connect($dbcfg)); break; default: } return $querybuilder[$dbcfg]; }
/** * FL运行目录 * * @var string */ define('FL_RUNDIR', FL_PATH); } /** * 临时目录 * * @var string */ define('FL_TMP', FL_RUNDIR . DIRECTORY_SEPARATOR . 'tmp'); /** * Fastlib 版本信息 */ define("FL_VERSION", '0.0.1'); if (!fl\base\core::iscli()) { header('x-powered-by: fastlib ver ' . FL_VERSION); header('software: fastlib ver ' . FL_VERSION); } $cfg = \fl\cfg\cfg::getcfgobj('site', 'ini'); define('FL_DEBUG', $cfg->get('main', 'debug')); if (FL_DEBUG) { error_reporting((E_ALL | E_STRICT) & ~E_NOTICE); } else { error_reporting(0); } if ($cfg->get('main', 'timezone')) { date_default_timezone_set($cfg->get('main', 'timezone')); }