Ejemplo n.º 1
0
 public function connect()
 {
     //    $m = new Memcache();
     //    $m->addServer('localhost', 11211);
     //    $v = $m->get('counter');
     //    $m->set('counter', $v + 1);
     //
     //    $md = new Memcached();
     //    $md->addServer('localhost', 11211);
     //    $v = $md->get('counter', null, $token);
     //    $v = $md->set('counter', null,1, $token);
     auto::isDebugMode() && ($_debugMicrotime = microtime(true));
     $memcachedClass = 'Memcached';
     try {
         auto::autoload($memcachedClass);
     } catch (Exception $ex) {
         throw new exception_cache('class not exist for ' . $memcachedClass . ', check your php extensions~', exception_cache::type_memcached_not_exist);
     }
     $this->_memcached = new $memcachedClass();
     $servers = $this->_confs['servers'];
     foreach ($servers as $server) {
         $this->_memcached->addServer($server['host'], $server['port'], $server['weight']);
     }
     auto::isDebugMode() && auto::dqueue(__METHOD__, 'cost ' . (microtime(true) - $_debugMicrotime) . 's, alias: ' . $this->_alias . ',conf ' . var_export($this->_confs, true));
     //return $this->_memcached;
     return $this;
 }
Ejemplo n.º 2
0
 public function connect()
 {
     auto::isDebugMode() && ($_debugMicrotime = microtime(true));
     $memcacheClass = 'Memcache';
     try {
         auto::autoload($memcacheClass);
     } catch (Exception $ex) {
         throw new exception_cache('class not exist for ' . $memcacheClass . ', check your php extensions~', exception_cache::type_memcache_not_exist);
     }
     $this->_memcache = new $memcacheClass();
     $servers = $this->_confs['servers'];
     foreach ($servers as $server) {
         $this->_memcache->addServer($server['host'], $server['port'], false, $server['weight']);
     }
     auto::isDebugMode() && auto::dqueue(__METHOD__, 'cost ' . (microtime(true) - $_debugMicrotime) . 's, alias: ' . $this->_alias . ',conf ' . var_export($this->_confs, true));
     //return $this->_memcache;
     return $this;
 }