Memcache::addServer
Add a memcached server to connection pool
Description
boolMemcache::addServer
stringhost
intport
boolpersistent
intweight
inttimeout
intretry_interval
Memcache::addServer adds a server to the connection
pool. The actual connection is established on first use.
Parameters host and port point
to the host and port, where memcached is listening for connections.
Parameter port is optional, it's default value is
11211.
Parameter persistent controls the use of a persistent
connection, the default is &true;.
Parameter weight is the 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.
You can define a timeout (in seconds), which will be
used when 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.
Parameter retry_interval controls how often a failed server
will be retried, the default value is 15 seconds. Neither this nor the
persistent parameter has any effect when this extension
is loaded dynamically via dl.
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.
See example below.
Memcache::addServer 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);
?>
]]>
&return.success;
See also
Memcache::connect,
Memcache::pconnect and
Memcache::close and