<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/class.memcached.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'it',
  ),
  'this' => 
  array (
    0 => 'memcached.addserver.php',
    1 => 'Memcached::addServer',
    2 => 'Add a server to the server pool',
  ),
  'up' => 
  array (
    0 => 'class.memcached.php',
    1 => 'Memcached',
  ),
  'prev' => 
  array (
    0 => 'memcached.addbykey.php',
    1 => 'Memcached::addByKey',
  ),
  'next' => 
  array (
    0 => 'memcached.addservers.php',
    1 => 'Memcached::addServers',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/memcached/memcached/addserver.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="memcached.addserver" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">Memcached::addServer</h1>
  <p class="verinfo">(PECL memcached &gt;= 0.1.0)</p><p class="refpurpose"><span class="refname">Memcached::addServer</span> &mdash; <span class="dc-title">Add a server to the server pool</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-memcached.addserver-description">
  <h3 class="title">Descrizione</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>Memcached::addServer</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$host</code></span>, <span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$port</code></span>, <span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$weight</code><span class="initializer"> = 0</span></span>): <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span></div>

  <p class="para rdfs-comment">
   <span class="function"><strong>Memcached::addServer()</strong></span> adds the specified server to the
   server pool. No connection is established to the server at this time, but
   if you are using consistent key distribution option (via
   <strong><code><a href="memcached.constants.php#memcached.constants.distribution-consistent">Memcached::DISTRIBUTION_CONSISTENT</a></code></strong> or
   <strong><code><a href="memcached.constants.php#memcached.constants.opt-libketama-compatible">Memcached::OPT_LIBKETAMA_COMPATIBLE</a></code></strong>), some of the
   internal data structures will have to be updated. Thus, if you need to add
   multiple servers, it is better to use
   <span class="methodname"><a href="memcached.addservers.php" class="methodname">Memcached::addServers()</a></span> as the update then happens
   only once.
  </p>
  <p class="para">
   The same server may appear multiple times in the server pool, because no
   duplication checks are made. This is not advisable; instead, use the
   <code class="parameter">weight</code> option to increase the selection weighting of
   this server.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-memcached.addserver-parameters">
  <h3 class="title">Elenco dei parametri</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">host</code></dt>
     <dd>
      <p class="para">
       The hostname of the memcache server. If the hostname is invalid,
       data-related operations will set 
       <strong><code><a href="memcached.constants.php#memcached.constants.res-host-lookup-failure">Memcached::RES_HOST_LOOKUP_FAILURE</a></code></strong> result code. As
       of version 2.0.0b1, this parameter may also specify the path of a unix
       socket filepath ex. <code class="literal">/path/to/memcached.sock</code>
       to use UNIX domain sockets, in this case <code class="parameter">port</code>
       must also be set to <code class="literal">0</code>.
      </p>
     </dd>
    
    
     <dt><code class="parameter">port</code></dt>
     <dd>
      <p class="para">
       The port on which memcache is running. Usually, this is
       <code class="literal">11211</code>. As of version 2.0.0b1, set this parameter to <code class="literal">0</code> when 
       using UNIX domain sockets.
      </p>
     </dd>
    
    
     <dt><code class="parameter">weight</code></dt>
     <dd>
      <p class="para">
       The weight of the server relative to the total weight of all the
       servers in the pool. This controls the probability of the server being
       selected for operations. This is used only with consistent distribution
       option and usually corresponds to the amount of memory available to
       memcache on that server.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-memcached.addserver-returnvalues">
  <h3 class="title">Valori restituiti</h3>
  <p class="para">
   Restituisce <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> in caso di successo, <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> in caso di fallimento.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-memcached.addserver-examples">
  <h3 class="title">Esempi</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Example #1 <span class="function"><strong>Memcached::addServer()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$m </span><span style="color: #007700">= new </span><span style="color: #0000BB">Memcached</span><span style="color: #007700">();<br /><br /></span><span style="color: #FF8000">/* Add 2 servers, so that the second one<br />   is twice as likely to be selected. */<br /></span><span style="color: #0000BB">$m</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">addServer</span><span style="color: #007700">(</span><span style="color: #DD0000">'mem1.domain.com'</span><span style="color: #007700">, </span><span style="color: #0000BB">11211</span><span style="color: #007700">, </span><span style="color: #0000BB">33</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$m</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">addServer</span><span style="color: #007700">(</span><span style="color: #DD0000">'mem2.domain.com'</span><span style="color: #007700">, </span><span style="color: #0000BB">11211</span><span style="color: #007700">, </span><span style="color: #0000BB">67</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-memcached.addserver-seealso">
  <h3 class="title">Vedere anche:</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="methodname"><a href="memcached.addservers.php" class="methodname" rel="rdfs-seeAlso">Memcached::addServers()</a> - Add multiple servers to the server pool</span></li>
    <li><span class="methodname"><a href="memcached.resetserverlist.php" class="methodname" rel="rdfs-seeAlso">Memcached::resetServerList()</a> - Clears all servers from the server list</span></li>
   </ul>
  </p>
 </div>


</div><?php manual_footer($setup); ?>