Esempio n. 1
0
 public function __construct()
 {
     $dbConfig = Config::getDbConfig();
     $db_factory = new Factory($dbConfig);
     $this->db_adapter = $db_factory->getDBAdapter();
     $cacheFactory = new CacheAdapter('redis');
     $this->sql_helper = new Sql();
     $this->cache_adapter = $cacheFactory->getCacheAdapter();
 }
Esempio n. 2
0
 /**
  * 获得Factory对象
  * @param string $cache_adapter
  * @throws Exception
  */
 function __construct($name)
 {
     $env = getenv('RUNTIME_ENVIROMENT') ? getenv('RUNTIME_ENVIROMENT') : (defined('SHELL_VARIABLE') ? SHELL_VARIABLE : '');
     $env = empty($env) ? 'local' : $env;
     $cache_config = Config::getCacheConfig();
     $config = $cache_config['cache'][$name];
     if (!is_array($config)) {
         throw new \Exception('缓存配置错误');
     }
     $this->cache_config = $config[$env];
     $this->adapter = $name;
 }