public function get_backend() { if (!extension_loaded('memcached')) { throw new MemcachedNotLoadedError(); } if (static::$_default_connection instanceof \Memcached) { return static::$_default_connection; } $this->_load_config(); $this->_check_config(); $m = new \Memcached(); foreach ($this->_config['memcached'] as $server) { $m->addServer($server['host'], $server['port']); } static::$_default_connection = $m; return $m; }
public function get_backend($write = False) { if (!class_exists('\\HandlerSocket')) { throw new HSNotLoadedError(); } $this->_load_config(); $this->_check_config(); if (static::$_default_connection) { return static::$_default_connection; } $conf = $this->_config['handlersocket']; $handlersocket = new \HandlerSocket($conf['host'], $conf['port']); $handlersocket_wr = new \HandlerSocket($conf['host'], $conf['port_wr']); $hs = HS::create()->set_handlersocket($handlersocket, $handlersocket_wr)->set_db($this->get_db_name()); static::$_default_connection = $hs; return $hs; }
public function __destroy() { static::$_default_connection = null; }