예제 #1
0
 /**
  * @param string $className
  * @return ILogger
  */
 public static function getLogger($className = '')
 {
     if (empty($className)) {
         $className = Loader::getInstance()->getConfig('log_class');
     }
     if (!isset(self::$_loggers[$className])) {
         $log_priority = Loader::getInstance()->getConfig('log_priority');
         self::$_loggers[$className] = new $className($log_priority);
     }
     return self::$_loggers[$className];
 }
예제 #2
0
 /**
  * @param bool|false $configKey
  * @return bool|IDaoAdapter
  */
 public function getDao($configKey = 'default')
 {
     if (!isset(self::$_daoList[$configKey])) {
         $dbConfig = Loader::getInstance()->getConfig($configKey, 'database');
         if (!isset($dbConfig) || empty($dbConfig['adapter_class'])) {
             trigger_error('No "adapter_class" config item found in "database.php"', E_USER_ERROR);
             return false;
         }
         self::$_daoList[$configKey] = new $dbConfig['adapter_class']($dbConfig);
     }
     return self::$_daoList[$configKey];
 }
예제 #3
0
파일: CacheFactory.php 프로젝트: zhxia/nspf
 /**
  * @param string $name
  * @return \Memcached
  */
 public function getMemcached($name = 'default')
 {
     $instKey = 'memcached-' . $name;
     if (!isset(self::$_cacheInstances[$instKey])) {
         $redisConfig = Loader::getInstance()->getConfig('memcached', 'cache');
         if (!isset($redisConfig[$name])) {
             trigger_error('can not get config item:"memcached.' . $name . '" from cache config file!');
         }
         $serverConfig = $redisConfig[$name];
         self::$_cacheInstances[$instKey] = new Memcached($serverConfig);
     }
     return self::$_cacheInstances[$instKey];
 }