Memcache::addServer Add a memcached server to connection pool &reftitle.description; boolMemcache::addServer stringhost intport boolpersistent intweight inttimeout intretry_interval boolstatus callbackfailure_callback Memcache::addServer adds a server to the connection pool. The actual connection is established on first use. The connection, which was opened using Memcache::addServer will be automatically closed at the end of script execution. Also you can close it with Memcache::close. You can also use the memcache_add_server function. Failover may occur at any stage in any of the methods, as long as other servers are available the request the user won't notice. Any kind of socket or Memcached server level errors (except out-of-memory) may trigger the failover. Normal client errors such as adding an existing key will not trigger a failover. This function has been added to Memcache version 2.0.0. &reftitle.parameters; host Point to the host where memcached is listening for connections. port Point to the port where memcached is listening for connections. This parameter is optional and its default value is 11211. persistent Controls the use of a persistent connection. Default to &true;. weight Number of buckets to create for this server which in turn control its probability of it being selected. The probability is relative to the total weight of all servers. timeout Value in seconds which will be used for connecting to the daemon. Think twice before changing the default value of 1 second - you can loose all the advantages of caching if your connection is too slow. retry_interval Controls how often a failed server will be retried, the default value is 15 seconds. Setting this parameter to -1 disables automatic retry. Neither this nor the persistent parameter has any effect when the extension is loaded dynamically via dl. Each failed connection struct has its own timeout and before it has expired the struct will be skipped when selecting backends to serve a request. Once expired the connection will be successfully reconnected or marked as failed for another retry_interval seconds. The typical effect is that each webserver child will retry the connection about every retry_interval seconds when serving a page. status Controls if the server should be flagged as online. Setting this parameter to &false; and retry_interval to -1 allows a failed server to be kept in the pool so as not to affect the key distribution algoritm. Requests for this server will then failover or fail immediatly depending on the memcache.allow_failover setting. Default to &true;, meaning the server should be considered online. failure_callback Allows the user to specify a callback function to run upon encountering an error. The callback is run before failover is attemped. The function takes two parameters, the hostname and port of the failed server. &reftitle.returnvalues; &return.success; &reftitle.examples; <function>Memcache::addServer</function> example addServer('memcache_host', 11211); $memcache->addServer('memcache_host2', 11211); /* procedural API */ $memcache_obj = memcache_connect('memcache_host', 11211); memcache_add_server($memcache_obj, 'memcache_host2', 11211); ?> ]]> &reftitle.seealso; Memcache::connect Memcache::pconnect Memcache::close Memcache::setServerParams Memcache::getServerStatus