Ejemplo n.º 1
0
 public function connect()
 {
     if (!isset(self::$_cacheObj)) {
         if (defined('CACHE_MEMCACHED_CONFIG') && constant('CACHE_MEMCACHED_CONFIG')) {
             self::$_cacheObj = new Memcached();
             $config = explode(',', CACHE_MEMCACHE_CONFIG);
             foreach ($config as $row) {
                 $row = trim($row);
                 if (strpos($row, 'unix://') === 0) {
                 } else {
                     $tmp = explode(':', $row);
                     self::$_cacheObj->addServer($tmp[0], $tmp[1]);
                 }
             }
         } else {
             trigger_error('can\'t load CACHE_MEMCACHED_CONFIG, please check it', E_USER_ERROR);
         }
     }
 }
Ejemplo n.º 2
0
 public function connect()
 {
     if (!isset(self::$_cacheObj)) {
         $hosts = (array) config::get('cache.base_cache_memcached.hosts');
         if (!empty($hosts)) {
             self::$_cacheObj = new Memcached();
             foreach ($hosts as $row) {
                 $row = trim($row);
                 if (strpos($row, 'unix://') === 0) {
                     //self::$_cacheObj->addServer($row, 0);  todo:memcached不支持unix://
                 } else {
                     $tmp = explode(':', $row);
                     self::$_cacheObj->addServer($tmp[0], $tmp[1]);
                 }
             }
         } else {
             trigger_error('cache:base_cache_memcached hosts is empty, please check it', E_USER_ERROR);
         }
     }
 }