Ejemplo n.º 1
0
 /**
  * @param array $servers List of servers
  * @param int $expire Expiration time, defaults to 3600 seconds
  * @throws \Exception
  */
 public function __construct($servers = [], $expire = 3600)
 {
     // Set expiration time
     $this->expire = $expire;
     // Create memcached object
     $this->cache = new \Memcached();
     // Check if there already are servers added, according to the manual
     // http://php.net/manual/en/memcached.addservers.php no duplication checks
     // are made. Since we have at least one connection we don't need to add
     // more servers and maybe add duplicates.
     if (count($this->cache->getServerList()) === 0) {
         // Add servers
         $this->cache->addServers($servers);
     }
     // Get server stats
     $stats = $this->cache->getStats();
     // Loop through servers
     foreach ($stats as $stat) {
         // Check if pid is more than 0, if pid is -1 connection isn't working
         if ($stat['pid'] > 0) {
             // Return true to avoid the exception below
             return true;
         }
     }
     // If we end up here we don't have a working connection. Throw an exception that
     // will be handled by the method calling this connect method. A working cache is
     // NOT a requirement for the application to run so it's important to handle the
     // exception and let the application run. Suggestion: if the exception below is
     // thrown a new NullCache should be created
     throw new \Exception('Unable to connect to Memcache(d) backend');
 }
 /**
  * Constructor
  *
  * @param array[] $servers server array
  */
 public function __construct($servers)
 {
     if (!$servers || !is_array($servers) || count($servers) < 1) {
         throw new GitPHP_MessageException('No Memcache servers defined', true, 500);
     }
     if (class_exists('Memcached')) {
         $this->memcacheObj = new Memcached();
         $this->memcacheType = GitPHP_CacheResource_Memcache::Memcached;
         $this->memcacheObj->addServers($servers);
     } else {
         if (class_exists('Memcache')) {
             $this->memcacheObj = new Memcache();
             $this->memcacheType = GitPHP_CacheResource_Memcache::Memcache;
             foreach ($servers as $server) {
                 if (is_array($server)) {
                     $host = $server[0];
                     $port = 11211;
                     if (isset($server[1])) {
                         $port = $server[1];
                     }
                     $weight = 1;
                     if (isset($server[2])) {
                         $weight = $server[2];
                     }
                     $this->memcacheObj->addServer($host, $port, true, $weight);
                 }
             }
         } else {
             throw new GitPHP_MissingMemcacheException();
         }
     }
     $this->servers = $servers;
 }
Ejemplo n.º 3
0
 public function __construct($prefix = '')
 {
     parent::__construct($prefix);
     if (is_null(self::$cache)) {
         self::$cache = new \Memcached();
         $servers = \OC::$server->getSystemConfig()->getValue('memcached_servers');
         if (!$servers) {
             $server = \OC::$server->getSystemConfig()->getValue('memcached_server');
             if ($server) {
                 $servers = array($server);
             } else {
                 $servers = array(array('localhost', 11211));
             }
         }
         self::$cache->addServers($servers);
         $defaultOptions = [\Memcached::OPT_CONNECT_TIMEOUT => 50, \Memcached::OPT_RETRY_TIMEOUT => 50, \Memcached::OPT_SEND_TIMEOUT => 50, \Memcached::OPT_RECV_TIMEOUT => 50, \Memcached::OPT_POLL_TIMEOUT => 50, \Memcached::OPT_COMPRESSION => true, \Memcached::OPT_LIBKETAMA_COMPATIBLE => true, \Memcached::OPT_BINARY_PROTOCOL => true];
         // by default enable igbinary serializer if available
         if (\Memcached::HAVE_IGBINARY) {
             $defaultOptions[\Memcached::OPT_SERIALIZER] = \Memcached::SERIALIZER_IGBINARY;
         }
         $options = \OC::$server->getConfig()->getSystemValue('memcached_options', []);
         if (is_array($options)) {
             $options = $options + $defaultOptions;
             self::$cache->setOptions($options);
         } else {
             throw new HintException("Expected 'memcached_options' config to be an array, got {$options}");
         }
     }
 }
Ejemplo n.º 4
0
 /**
  * Constructor
  *
  * @access public
  *
  * @param array $config config array
  *
  * @result void
  * @throws Exception
  */
 public function __construct(array $config = [])
 {
     parent::__construct($config);
     if (empty($config['type']) || !$this->check()) {
         throw new Exception('Memcache(d) not installed or not select type');
     }
     switch (strtolower($config['type'])) {
         case 'memcached':
             $this->driver = new \Memcached();
             break;
         case 'memcache':
             $this->driver = new \Memcache();
             break;
         default:
             throw new Exception('Selected type not valid in the driver');
     }
     if (!empty($config['servers'])) {
         $this->driver->addServers($config['servers']);
     } elseif ($config['server']) {
         $conf = $config['server'];
         $server = ['hostname' => !empty($conf['hostname']) ? $conf['hostname'] : '127.0.0.1', 'port' => !empty($conf['port']) ? $conf['port'] : 11211, 'weight' => !empty($conf['weight']) ? $conf['weight'] : 1];
         if (get_class($this->driver) === 'Memcached') {
             $this->driver->addServer($server['hostname'], $server['port'], $server['weight']);
         } else {
             $this->driver->addServer($server['hostname'], $server['port'], true, $server['weight']);
         }
     } else {
         throw new Exception('Server(s) not configured');
     }
 }
Ejemplo n.º 5
0
 /**
  * @return \Memcached
  */
 public function getMemcached()
 {
     if (!$this->Memcached) {
         $this->Memcached = new \Memcached();
         $this->Memcached->addServers($this->options['servers']);
     }
     return $this->Memcached;
 }
Ejemplo n.º 6
0
 /**
  * {@inheritDoc}
  */
 public function addServers(array $servers)
 {
     $configs = [];
     foreach ($servers as $server) {
         $configs[] = [$server['host'], $server['port']];
     }
     $this->_connection->addServers($configs);
 }
Ejemplo n.º 7
0
 public static function setUpBeforeClass()
 {
     self::$memcached = new \Memcached();
     self::$memcached->setOptions(array(\Memcached::OPT_TCP_NODELAY => true, \Memcached::OPT_NO_BLOCK => true, \Memcached::OPT_CONNECT_TIMEOUT => 1000));
     if (count(self::$memcached->getServerList()) == 0) {
         self::$memcached->addServers(array(array(MEMCACHED_HOST, MEMCACHED_PORT)));
     }
 }
Ejemplo n.º 8
0
 /**
  * Construct the driver instance.
  *
  * @param Config $config The instance config
  */
 public function __construct(Config $config, Instance $instance)
 {
     $this->instance = $instance;
     $this->client = new \Memcached($config->name);
     if (count($this->client->getServerList()) === 0) {
         $this->client->addServers($config->servers->toArray());
     }
 }
Ejemplo n.º 9
0
 /**
  * Constructor
  * @param array $options cache store storage option
  */
 public function __construct($options = array())
 {
     $this->connect = new \Memcached();
     $this->prefix = $options['prefix'];
     $this->default_ttl = $options['default_ttl'];
     $this->connect->setOption(\Memcached::OPT_PREFIX_KEY, $this->prefix);
     $this->connect->addServers($options['servers']);
 }
Ejemplo n.º 10
0
	/**
	 * Creates a new instance of memcached.
	 */
	public function __construct() {
		if (!class_exists('Memcached')) {
			throw new SystemException('memcached support is not enabled.');
		}
		
		// init memcached
		$this->memcached = new \Memcached();
		
		// add servers
		$tmp = explode("\n", StringUtil::unifyNewlines(CACHE_SOURCE_MEMCACHED_HOST));
		$servers = array();
		$defaultWeight = floor(100 / count($tmp));
		$regex = new Regex('^\[([a-z0-9\:\.]+)\](?::([0-9]{1,5}))?(?::([0-9]{1,3}))?$', Regex::CASE_INSENSITIVE);
		
		foreach ($tmp as $server) {
			$server = StringUtil::trim($server);
			if (!empty($server)) {
				$host = $server;
				$port = 11211; // default memcached port
				$weight = $defaultWeight;
				
				// check for IPv6
				if ($regex->match($host)) {
					$matches = $regex->getMatches();
					$host = $matches[1];
					if (isset($matches[2])) {
						$port = $matches[2];
					}
					if (isset($matches[3])) {
						$weight = $matches[3];
					}
				}
				else {
					// IPv4, try to get port and weight
					if (strpos($host, ':')) {
						$parsedHost = explode(':', $host);
						$host = $parsedHost[0];
						$port = $parsedHost[1];
						
						if (isset($parsedHost[2])) {
							$weight = $parsedHost[2];
						}
					}
				}
				
				$servers[] = array($host, $port, $weight);
			}
		}
		
		$this->memcached->addServers($servers);
		
		// test connection
		$this->memcached->get('testing');
		
		// set variable prefix to prevent collision
		$this->prefix = substr(sha1(WCF_DIR), 0, 8) . '_';
	}
Ejemplo n.º 11
0
 /**
  * @param       $persistentId
  * @param array $connections
  */
 public function __construct($persistentId, array $connections)
 {
     $this->isMemcachedExtensionAvailable();
     $this->memcached = new MemcachedDriver($persistentId);
     $this->memcached->addServers($connections);
     $this->memcached->setOption(MemcachedDriver::OPT_SERIALIZER, \defined(MemcachedDriver::HAVE_IGBINARY) && MemcachedDriver::HAVE_IGBINARY ? MemcachedDriver::SERIALIZER_IGBINARY : MemcachedDriver::SERIALIZER_PHP);
     $this->memcached->setOption(MemcachedDriver::OPT_DISTRIBUTION, MemcachedDriver::DISTRIBUTION_CONSISTENT);
     $this->memcached->setOption(MemcachedDriver::OPT_LIBKETAMA_COMPATIBLE, true);
     $this->memcached->setOption(MemcachedDriver::OPT_BINARY_PROTOCOL, true);
 }
Ejemplo n.º 12
0
 /**
  * Constructor
  *
  * @param array[] $servers server array
  */
 public function __construct($servers)
 {
     if (!class_exists('Memcached')) {
         throw new Exception('Memcached extension not found');
     }
     if (!$servers || !is_array($servers) || count($servers) < 1) {
         throw new GitPHP_MessageException('No Memcache servers defined', true, 500);
     }
     $this->memcache = new Memcached();
     $this->memcache->addServers($servers);
 }
Ejemplo n.º 13
0
 /**
  * Configure servers
  *
  * @return void
  *
  * @throws \InvalidArgumentException
  */
 public function configureServers()
 {
     if (!array_key_exists('server', $this->config)) {
         throw new \InvalidArgumentException('Configuration key "server" must be set');
     }
     $servers = $this->config['server'];
     // Single server
     if (array_key_exists('host', $servers)) {
         $servers = array($servers);
     }
     $this->connection->addServers($servers);
 }
Ejemplo n.º 14
0
 /**
  * Get Mamcached Handler
  *
  * @return \Memcached
  */
 public function getHandler()
 {
     if (!$this->handler) {
         $persistentId = isset($this->settings['persistent']) ? $this->settings['persistent'] : null;
         $this->handler = new \Memcached($persistentId);
         if (!$this->handler->getServerList()) {
             $this->handler->addServers($this->settings['servers']);
         }
         if (isset($this->settings['options'])) {
             $this->handler->setOptions($this->settings['options']);
         }
     }
     return $this->handler;
 }
Ejemplo n.º 15
0
 /**
  * Constructor
  *
  * @param  null|array|Traversable|MemcachedOptions $options
  * @throws Exception\ExceptionInterface
  */
 public function __construct($options = null)
 {
     if (static::$extMemcachedMajorVersion === null) {
         $v = (string) phpversion('memcached');
         static::$extMemcachedMajorVersion = $v !== '' ? (int) $v[0] : 0;
     }
     if (static::$extMemcachedMajorVersion < 1) {
         throw new Exception\ExtensionNotLoadedException('Need ext/memcached version >= 1.0.0');
     }
     parent::__construct($options);
     // It's ok to init the memcached instance as soon as possible because
     // ext/memcached auto-connects to the server on first use
     $this->memcached = new MemcachedResource();
     $options = $this->getOptions();
     // set lib options
     if (static::$extMemcachedMajorVersion > 1) {
         $this->memcached->setOptions($options->getLibOptions());
     } else {
         foreach ($options->getLibOptions() as $k => $v) {
             $this->memcached->setOption($k, $v);
         }
     }
     $this->memcached->setOption(MemcachedResource::OPT_PREFIX_KEY, $options->getNamespace());
     $servers = $options->getServers();
     if (!$servers) {
         $options->addServer('127.0.0.1', 11211);
         $servers = $options->getServers();
     }
     $this->memcached->addServers($servers);
     // get notified on change options
     $memc = $this->memcached;
     $memcMV = static::$extMemcachedMajorVersion;
     $this->getEventManager()->attach('option', function ($event) use($memc, $memcMV) {
         $params = $event->getParams();
         if (isset($params['lib_options'])) {
             if ($memcMV > 1) {
                 $memc->setOptions($params['lib_options']);
             } else {
                 foreach ($params['lib_options'] as $k => $v) {
                     $memc->setOption($k, $v);
                 }
             }
         }
         if (isset($params['namespace'])) {
             $memc->setOption(MemcachedResource::OPT_PREFIX_KEY, $params['namespace']);
         }
         // TODO: update on change/add server(s)
     });
 }
Ejemplo n.º 16
0
 /**
  * Connect to the cache server(s).
  *
  * @throws CacheException
  * @access private
  */
 private function connect()
 {
     $this->connected = false;
     switch (NN_CACHE_TYPE) {
         case self::TYPE_REDIS:
             if ($this->socketFile === false) {
                 $servers = unserialize(NN_CACHE_HOSTS);
                 foreach ($servers as $server) {
                     if ($this->server->connect($server['host'], $server['port'], (double) NN_CACHE_TIMEOUT) === false) {
                         throw new CacheException('Error connecting to the Redis server!');
                     } else {
                         $this->connected = true;
                     }
                 }
             } else {
                 if ($this->server->connect(NN_CACHE_SOCKET_FILE) === false) {
                     throw new CacheException('Error connecting to the Redis server!');
                 } else {
                     $this->connected = true;
                 }
             }
             break;
         case self::TYPE_MEMCACHED:
             $params = $this->socketFile === false ? unserialize(NN_CACHE_HOSTS) : [[NN_CACHE_SOCKET_FILE, 'port' => 0]];
             if ($this->server->addServers($params) === false) {
                 throw new CacheException('Error connecting to the Memcached server!');
             } else {
                 $this->connected = true;
             }
             break;
         case self::TYPE_APC:
             $this->connected = true;
             break;
     }
 }
Ejemplo n.º 17
0
 /**
  *
  * @param array $servers Each entry in servers is supposed to be an array
  *  containing hostname, port, and, optionally, weight of the server.
  * $servers = array(
  * array('mem1.domain.com', 11211, 33),
  * array('mem2.domain.com', 11211, 67)
  * );
  * @return boolean
  * @codeCoverageIgnore
  */
 public function addServers($servers)
 {
     if (!self::hasMemcachedExt()) {
         return false;
     }
     return $this->memcached->addServers($servers);
 }
Ejemplo n.º 18
0
 /**
  * Adds an array of servers to the pool.
  *
  * Each individual server in the array must include a domain and port, with an optional
  * weight value: $servers = array( array( '127.0.0.1', 11211, 0 ) );
  *
  * @link    http://www.php.net/manual/en/memcached.addservers.php
  *
  * @param   array       $servers        Array of server to register.
  * @return  bool                        True on success; false on failure.
  */
 public function addServers($servers)
 {
     if (!is_object($this->mc)) {
         return false;
     }
     return $this->mc->addServers($servers);
 }
Ejemplo n.º 19
0
 /**
  * @return \Memcached
  */
 protected function getMemcached()
 {
     $Memcached = new \Memcached();
     $Memcached->addServers($this->getTestServers());
     $Memcached->flush();
     return $Memcached;
 }
Ejemplo n.º 20
0
 protected function __construct($config)
 {
     if (empty($config)) {
         throw new \exception('invalid!');
     }
     $c = new \Memcached('sk_cache');
     //$c->resetserverlist();
     $config_servers = $config['servers'];
     //easier to keep the code straight this way.
     $used_servers = $c->getServerList();
     $count_servers_used = count($used_servers);
     $count_servers_config = count($config_servers);
     if (!$count_servers_used) {
         //we have no servers stored. store the entire array.
         $c->addServers($config_servers);
     } else {
         //we need to check to see if a new server was added to the config.
         if ($count_servers_used < $count_servers_config) {
             $used = array_column($used_servers, 0);
             //0 index is ip, 1 index is port...
             $config = array_column($config_servers, 0);
             usort($used, ['self', 'sortServers']);
             usort($config, ['self', 'sortServers']);
             $diff = $count_servers_config - $count_servers_used;
             $new = array_slice($config, $count_servers_used - 1);
             foreach ($new as $server) {
                 $c->addServer($server, 11211);
                 //to do: find a way to retrieve the port of the server when adding it, in case of people with custom ports for memcache.
             }
         }
     }
     $this->driver = $c;
     self::$instance =& $this;
 }
Ejemplo n.º 21
0
 /**
  * Initialize the Cache Engine
  *
  * Called automatically by the cache frontend
  *
  * @param array $config array of setting for the engine
  * @return bool True if the engine has been successfully initialized, false if not
  * @throws \InvalidArgumentException When you try use authentication without
  *   Memcached compiled with SASL support
  */
 public function init(array $config = [])
 {
     if (!extension_loaded('memcached')) {
         return false;
     }
     $this->_serializers = ['igbinary' => Memcached::SERIALIZER_IGBINARY, 'json' => Memcached::SERIALIZER_JSON, 'php' => Memcached::SERIALIZER_PHP];
     if (defined('Memcached::HAVE_MSGPACK') && Memcached::HAVE_MSGPACK) {
         $this->_serializers['msgpack'] = Memcached::SERIALIZER_MSGPACK;
     }
     parent::init($config);
     if (!empty($config['host'])) {
         if (empty($config['port'])) {
             $config['servers'] = [$config['host']];
         } else {
             $config['servers'] = [sprintf('%s:%d', $config['host'], $config['port'])];
         }
     }
     if (isset($config['servers'])) {
         $this->config('servers', $config['servers'], false);
     }
     if (!is_array($this->_config['servers'])) {
         $this->_config['servers'] = [$this->_config['servers']];
     }
     if (isset($this->_Memcached)) {
         return true;
     }
     if ($this->_config['persistent']) {
         $this->_Memcached = new Memcached((string) $this->_config['persistent']);
     } else {
         $this->_Memcached = new Memcached();
     }
     $this->_setOptions();
     if (count($this->_Memcached->getServerList())) {
         return true;
     }
     $servers = [];
     foreach ($this->_config['servers'] as $server) {
         $servers[] = $this->_parseServerString($server);
     }
     if (!$this->_Memcached->addServers($servers)) {
         return false;
     }
     if (is_array($this->_config['options'])) {
         foreach ($this->_config['options'] as $opt => $value) {
             $this->_Memcached->setOption($opt, $value);
         }
     }
     if (empty($this->_config['username']) && !empty($this->_config['login'])) {
         throw new InvalidArgumentException('Please pass "username" instead of "login" for connecting to Memcached');
     }
     if ($this->_config['username'] !== null && $this->_config['password'] !== null) {
         $sasl = method_exists($this->_Memcached, 'setSaslAuthData') && ini_get('memcached.use_sasl');
         if (!$sasl) {
             throw new InvalidArgumentException('Memcached extension is not build with SASL support');
         }
         $this->_Memcached->setOption(Memcached::OPT_BINARY_PROTOCOL, true);
         $this->_Memcached->setSaslAuthData($this->_config['username'], $this->_config['password']);
     }
     return true;
 }
Ejemplo n.º 22
0
 public function __construct(array $config)
 {
     if (!extension_loaded('memcached')) {
         throw Error::require_extension('memcached');
     }
     $memcached = new \Memcached();
     if (isset($config['servers'])) {
         $memcached->addServers($config['servers']);
     } else {
         list($host, $port) = \Lysine\array_get($config, 'server') ?: $this->default_server;
         $memcached->addServer($host, $port);
     }
     if (isset($config['life_time'])) {
         $this->life_time = $config['life_time'];
     }
     if (isset($config['prefix'])) {
         $this->setPrefix($config['prefix']);
     }
     if (isset($config['options'])) {
         foreach ($config['options'] as $key => $val) {
             $memcache->setOption($key, $val);
         }
     }
     $this->memcached = $memcached;
 }
Ejemplo n.º 23
0
 /**
  * 生成Memcached实例
  *
  * @param array  $serverList
  * @param string $persistentId 持久连接的名称
  * @return \Memcached
  */
 public static function memcached(array $serverList, $persistentId = '')
 {
     $saver = new \Memcached($persistentId);
     if (!count($saver->getServerList())) {
         $saver->addServers($serverList);
     }
     return $saver;
 }
 /**
  *
  * @param integer $size
  * @param string|array $hosts Single host, many hosts with commas, or array
  *      of hosts -- which Memcached server(s) to connect to; default localhost
  */
 public function __construct($size = 1000000, $hosts = 'localhost')
 {
     $this->size = $size;
     $this->memcached = new \Memcached();
     if (!is_array($hosts)) {
         $hosts = explode(',', $hosts);
     }
     $servers = array();
     foreach ($hosts as $host) {
         $servers[] = array($host, 11211, 100);
     }
     $this->memcached->addServers($servers);
     $this->memcached->setOption(\Memcached::OPT_CONNECT_TIMEOUT, 100);
     $this->memcached->setOption(\Memcached::OPT_SEND_TIMEOUT, 50);
     $this->memcached->setOption(\Memcached::OPT_RECV_TIMEOUT, 50);
     $this->memcached->setOption(\Memcached::OPT_POLL_TIMEOUT, 250);
 }
Ejemplo n.º 25
0
 public function __construct($prefix = '')
 {
     parent::__construct($prefix);
     if (is_null(self::$cache)) {
         self::$cache = new \Memcached();
         $servers = \OC_Config::getValue('memcached_servers');
         if (!$servers) {
             $server = \OC_Config::getValue('memcached_server');
             if ($server) {
                 $servers = array($server);
             } else {
                 $servers = array(array('localhost', 11211));
             }
         }
         self::$cache->addServers($servers);
     }
 }
Ejemplo n.º 26
0
 /**
  * memcache 链接池
  * */
 public static function cache()
 {
     static $cache;
     if (!isset($cache)) {
         $cache = new Memcached();
         $cache->addServers(config::$memcacheServers);
     }
     return $cache;
 }
Ejemplo n.º 27
0
 /**
  * @param array  $servers Array of servers, where each server entry is in format array(SERVER_IP, SERVER_PORT, SERVER_WEIGHT), where SERVER_WEIGHT is optional (the bigger value, the bigger there is chance to be connected to that server).
  * @param string $prefix  Prefix for all the keys stored in memcached using this adapter.
  */
 public function __construct(array $servers, $prefix)
 {
     $driver = new MemcachedCache();
     $memcached = new \Memcached();
     $memcached->addServers($servers);
     $memcached->setOption(\Memcached::OPT_PREFIX_KEY, $prefix);
     $driver->setMemcached($memcached);
     $this->driver = $driver;
     parent::__construct($driver);
 }
Ejemplo n.º 28
0
 public function getStats($config)
 {
     if (!$config) {
         return array();
     }
     $memcached = new \Memcached();
     $memcached->setOption($memcached::OPT_PREFIX_KEY, $config['options']['namespace']);
     $memcached->addServers($config['options']['servers']);
     $stats = $memcached->getStats();
     return $stats;
 }
Ejemplo n.º 29
0
 /**
  * Maybe add server connections.
  *
  * @since 151216 Memcached utilities.
  */
 protected function maybeAddServerConnections()
 {
     if (!$this->Pool) {
         return;
         // Not possible.
     }
     if ($this->serversDiffer()) {
         $this->Pool->quit();
         $this->Pool->resetServerList();
         $this->Pool->addServers($this->servers);
     }
 }
Ejemplo n.º 30
0
 /**
  * Constructor
  *
  * @param  null|array|Traversable|MemcachedOptions $options
  * @throws Exception
  * @return void
  */
 public function __construct($options = null)
 {
     if (static::$extMemcachedMajorVersion === null) {
         $v = (string) phpversion('memcached');
         static::$extMemcachedMajorVersion = $v !== '' ? (int) $v[0] : 0;
     }
     if (static::$extMemcachedMajorVersion < 1) {
         throw new Exception\ExtensionNotLoadedException('Need ext/memcached version >= 1.0.0');
     }
     $this->memcached = new MemcachedResource();
     parent::__construct($options);
     // It's ok to add server as soon as possible because
     // ext/memcached auto-connects to the server on first use
     $options = $this->getOptions();
     $servers = $options->getServers();
     if (!$servers) {
         $options->addServer('localhost', 11211);
         $servers = $options->getServers();
     }
     $this->memcached->addServers($servers);
 }