mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-23 20:38:56 +00:00
103 lines
3.6 KiB
XML
103 lines
3.6 KiB
XML
![]() |
<?xml version="1.0" encoding="iso-8859-1"?>
|
||
|
<!-- $Revision: 1.1 $ -->
|
||
|
<refentry id="function.Memcache-addServer">
|
||
|
<refnamediv>
|
||
|
<refname>Memcache::addServer</refname>
|
||
|
<refpurpose>Add a memcached server to connection pool</refpurpose>
|
||
|
</refnamediv>
|
||
|
<refsect1>
|
||
|
<title>Description</title>
|
||
|
<methodsynopsis>
|
||
|
<type>bool</type><methodname>Memcache::addServer</methodname>
|
||
|
<methodparam><type>string</type><parameter>host</parameter></methodparam>
|
||
|
<methodparam choice="opt"><type>int</type><parameter>port</parameter></methodparam>
|
||
|
<methodparam choice="opt"><type>bool</type><parameter>persistent</parameter></methodparam>
|
||
|
<methodparam choice="opt"><type>int</type><parameter>weight</parameter></methodparam>
|
||
|
<methodparam choice="opt"><type>int</type><parameter>timeout</parameter></methodparam>
|
||
|
<methodparam choice="opt"><type>int</type><parameter>retry_interval</parameter></methodparam>
|
||
|
</methodsynopsis>
|
||
|
<para>
|
||
|
<function>Memcache::addServer</function> adds a server to the connection
|
||
|
pool. The actual connection is established on first use.
|
||
|
Parameters <parameter>host</parameter> and <parameter>port</parameter> point
|
||
|
to the host and port, where memcached is listening for connections.
|
||
|
Parameter <parameter>port</parameter> is optional, it's default value is
|
||
|
11211.
|
||
|
Parameter <parameter>persistent</parameter> controls the use of a persistent
|
||
|
connection, the default is &true;.
|
||
|
Parameter <parameter>weight</parameter> 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 <parameter>timeout</parameter> (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 <parameter>retry_interval</parameter> controls how often a failed server
|
||
|
will be retried, the default value is 15 seconds. Neither this nor the
|
||
|
<parameter>persistent</parameter> parameter has any effect when this extension
|
||
|
is loaded dynamically via <function>dl</function>.
|
||
|
</para>
|
||
|
<para>
|
||
|
The connection, which was opened using
|
||
|
<function>Memcache::addServer</function> will be automatically closed at the
|
||
|
end of script execution. Also you can close it with
|
||
|
<function>Memcache::close</function>.
|
||
|
</para>
|
||
|
<para>
|
||
|
You can also use the <function>memcache_add_server</function> function.
|
||
|
See example below.
|
||
|
</para>
|
||
|
<example>
|
||
|
<title><function>Memcache::addServer</function> example</title>
|
||
|
<programlisting role="php">
|
||
|
<![CDATA[
|
||
|
<?php
|
||
|
|
||
|
/* OO API */
|
||
|
|
||
|
$memcache = new Memcache;
|
||
|
$memcache->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);
|
||
|
|
||
|
?>
|
||
|
]]>
|
||
|
</programlisting>
|
||
|
</example>
|
||
|
<para>
|
||
|
&return.success;
|
||
|
</para>
|
||
|
<para>
|
||
|
See also
|
||
|
<function>Memcache::connect</function>,
|
||
|
<function>Memcache::pconnect</function> and
|
||
|
<function>Memcache::close</function> and
|
||
|
</para>
|
||
|
</refsect1>
|
||
|
</refentry>
|
||
|
|
||
|
<!-- Keep this comment at the end of the file
|
||
|
Local variables:
|
||
|
mode: sgml
|
||
|
sgml-omittag:t
|
||
|
sgml-shorttag:t
|
||
|
sgml-minimize-attributes:nil
|
||
|
sgml-always-quote-attributes:t
|
||
|
sgml-indent-step:1
|
||
|
sgml-indent-data:t
|
||
|
indent-tabs-mode:nil
|
||
|
sgml-parent-document:nil
|
||
|
sgml-default-dtd-file:"../../../../manual.ced"
|
||
|
sgml-exposed-tags:nil
|
||
|
sgml-local-catalogs:nil
|
||
|
sgml-local-ecat-files:nil
|
||
|
End:
|
||
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
||
|
vim: et tw=78 syn=sgml
|
||
|
vi: ts=1 sw=1
|
||
|
-->
|