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

contributors($setup);

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

 </div>

 <div class="refsect1 description" id="refsect1-memcache.addserver-description">
  <h3 class="title">Açıklama</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>Memcache::addServer</strong></span>(<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$host</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$port</code><span class="initializer"> = 11211</span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span> <code class="parameter">$persistent</code><span class="initializer"> = ?</span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<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"> = ?</span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$timeout</code><span class="initializer"> = ?</span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$retry_interval</code><span class="initializer"> = ?</span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span> <code class="parameter">$status</code><span class="initializer"> = ?</span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.callable.php" class="type callable">callable</a></span> <code class="parameter">$failure_callback</code><span class="initializer"> = ?</span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$timeoutms</code><span class="initializer"> = ?</span></span><br>): <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span></div>

    <div class="methodsynopsis dc-description"><span class="methodname"><strong>memcache_add_server</strong></span>(<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="class.memcache.php" class="type Memcache">Memcache</a></span> <code class="parameter">$memcache</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$host</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$port</code><span class="initializer"> = 11211</span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span> <code class="parameter">$persistent</code><span class="initializer"> = ?</span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<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"> = ?</span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$timeout</code><span class="initializer"> = ?</span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$retry_interval</code><span class="initializer"> = ?</span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span> <code class="parameter">$status</code><span class="initializer"> = ?</span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.callable.php" class="type callable">callable</a></span> <code class="parameter">$failure_callback</code><span class="initializer"> = ?</span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$timeoutms</code><span class="initializer"> = ?</span></span><br>): <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span></div>


  <p class="simpara">
   <span class="function"><strong>Memcache::addServer()</strong></span> adds a server to the connection pool.
  </p>

  <p class="simpara">
   When using this method (as opposed to <span class="function"><a href="memcache.connect.php" class="function">Memcache::connect()</a></span> and
   <span class="function"><a href="memcache.pconnect.php" class="function">Memcache::pconnect()</a></span>) the network connection is not established
   until actually needed. Thus there is no overhead in adding a large number of servers
   to the pool, even though they might not all be used.
  </p>

  <p class="simpara">
   Failover may occur at any stage in any of the methods, as long as other
   servers are available the request the user won&#039;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.
  </p>

  <blockquote class="note"><p><strong class="note">Bilginize</strong>: 
   <span class="simpara">
    This function has been added to Memcache version 2.0.0.
   </span>
  </p></blockquote>

 </div>


 <div class="refsect1 parameters" id="refsect1-memcache.addserver-parameters">
  <h3 class="title">Bağımsız Değişkenler</h3>
  <dl>
   
    <dt><code class="parameter">host</code></dt>
    <dd>
     <span class="simpara">
      Point to the host where memcached is listening for connections. This parameter
      may also specify other transports like <code class="literal">unix:///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>.
     </span>
    </dd>
   
   
    <dt><code class="parameter">port</code></dt>
    <dd>
     <span class="simpara">
      Point to the port where memcached is listening for connections.
      Set this
      parameter to <code class="literal">0</code> when using UNIX domain sockets.
     </span>
     <span class="simpara">
      Please note: <code class="parameter">port</code> defaults to
      <a href="memcache.ini.php#ini.memcache.default-port" class="link">memcache.default_port</a>
      if not specified. For this reason it is wise to specify the port
      explicitly in this method call.
     </span>
    </dd>
   
   
    <dt><code class="parameter">persistent</code></dt>
    <dd>
     <span class="simpara">
      Controls the use of a persistent connection. Default to <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong>.
     </span>
    </dd>
   
   
    <dt><code class="parameter">weight</code></dt>
    <dd>
     <span class="simpara">
      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.
     </span>
    </dd>
   
   
    <dt><code class="parameter">timeout</code></dt>
    <dd>
     <span class="simpara">
      Value in seconds which will be used for connecting to the daemon. Think
      twice before changing the default value of 1 second - you can lose all
      the advantages of caching if your connection is too slow.
     </span>
    </dd>
   
   
    <dt><code class="parameter">retry_interval</code></dt>
    <dd>
     <span class="simpara">
      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 <code class="parameter">persistent</code> parameter has any
      effect when the extension is loaded dynamically via <span class="function"><a href="function.dl.php" class="function">dl()</a></span>.
     </span>
     <span class="simpara">
      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 <code class="parameter">retry_interval</code> seconds. The typical
      effect is that each web server child will retry the connection about every
      <code class="parameter">retry_interval</code> seconds when serving a page.
     </span>
    </dd>
   
   
    <dt><code class="parameter">status</code></dt>
    <dd>
     <span class="simpara">
      Controls if the server should be flagged as online. Setting this parameter
      to <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> and <code class="parameter">retry_interval</code> to -1 allows a failed
      server to be kept in the pool so as not to affect the key distribution
      algorithm. Requests for this server will then failover or fail immediately
      depending on the <code class="parameter">memcache.allow_failover</code> setting.
      Default to <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong>, meaning the server should be considered online.
     </span>
    </dd>
   
   
    <dt><code class="parameter">failure_callback</code></dt>
    <dd>
     <span class="simpara">
      Allows the user to specify a callback function to run upon encountering an
      error. The callback is run before failover is attempted. The function takes
      two parameters, the hostname and port of the failed server.
     </span>
    </dd>
   
   
    <dt><code class="parameter">timeoutms</code></dt>
    <dd>
     <span class="simpara">

     </span>
    </dd>
   
  </dl>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-memcache.addserver-returnvalues">
  <h3 class="title">Dönen Değerler</h3>
  <p class="simpara">
   Başarı durumunda <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong>, başarısızlık durumunda <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> döner.
  </p>
 </div>


<div class="refsect1 examples" id="refsect1-memcache.addserver-examples">
  <h3 class="title">Örnekler</h3>
  <div class="example" id="example-1">
   <p><strong>Örnek 1 <span class="function"><strong>Memcache::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 /><br /></span><span style="color: #FF8000">/* OO API */<br /><br /></span><span style="color: #0000BB">$memcache </span><span style="color: #007700">= new </span><span style="color: #0000BB">Memcache</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$memcache</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">addServer</span><span style="color: #007700">(</span><span style="color: #DD0000">'memcache_host'</span><span style="color: #007700">, </span><span style="color: #0000BB">11211</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$memcache</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">addServer</span><span style="color: #007700">(</span><span style="color: #DD0000">'memcache_host2'</span><span style="color: #007700">, </span><span style="color: #0000BB">11211</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/* procedural API */<br /><br /></span><span style="color: #0000BB">$memcache_obj </span><span style="color: #007700">= </span><span style="color: #0000BB">memcache_connect</span><span style="color: #007700">(</span><span style="color: #DD0000">'memcache_host'</span><span style="color: #007700">, </span><span style="color: #0000BB">11211</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">memcache_add_server</span><span style="color: #007700">(</span><span style="color: #0000BB">$memcache_obj</span><span style="color: #007700">, </span><span style="color: #DD0000">'memcache_host2'</span><span style="color: #007700">, </span><span style="color: #0000BB">11211</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
   </div>

  </div>
 </div>


 <div class="refsect1 notes" id="refsect1-memcache.addserver-notes">
  <h3 class="title">Notlar</h3>
  <div class="warning"><strong class="warning">Uyarı</strong>
   <p class="simpara">
    When the <code class="parameter">port</code> is unspecified, this method defaults to the
    value set of the PHP ini directive
    <a href="memcache.ini.php#ini.memcache.default-port" class="link">memcache.default_port</a>
    If this value was changed elsewhere in your application it might lead to
    unexpected results: for this reason it is wise to always specify the port
    explicitly in this method call.
   </p>
  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-memcache.addserver-seealso">
  <h3 class="title">Ayrıca Bakınız</h3>
  <ul class="simplelist">
   <li><span class="function"><a href="memcache.connect.php" class="function" rel="rdfs-seeAlso">Memcache::connect()</a> - Open memcached server connection</span></li>
   <li><span class="function"><a href="memcache.pconnect.php" class="function" rel="rdfs-seeAlso">Memcache::pconnect()</a> - Open memcached server persistent connection</span></li>
   <li><span class="function"><a href="memcache.close.php" class="function" rel="rdfs-seeAlso">Memcache::close()</a> - Close memcached server connection</span></li>
   <li><span class="function"><a href="memcache.setserverparams.php" class="function" rel="rdfs-seeAlso">Memcache::setServerParams()</a> - Changes server parameters and status at runtime</span></li>
   <li><span class="function"><a href="memcache.getserverstatus.php" class="function" rel="rdfs-seeAlso">Memcache::getServerStatus()</a> - Returns server status</span></li>
  </ul>
 </div>


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