<?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.getserverbykey.php',
    1 => 'Memcached::getServerByKey',
    2 => 'Map a key to a server',
  ),
  'up' => 
  array (
    0 => 'class.memcached.php',
    1 => 'Memcached',
  ),
  'prev' => 
  array (
    0 => 'memcached.getresultmessage.php',
    1 => 'Memcached::getResultMessage',
  ),
  'next' => 
  array (
    0 => 'memcached.getserverlist.php',
    1 => 'Memcached::getServerList',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/memcached/memcached/getserverbykey.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="memcached.getserverbykey" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">Memcached::getServerByKey</h1>
  <p class="verinfo">(PECL memcached &gt;= 0.1.0)</p><p class="refpurpose"><span class="refname">Memcached::getServerByKey</span> &mdash; <span class="dc-title">Map a key to a server</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-memcached.getserverbykey-description">
  <h3 class="title">Descrizione</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>Memcached::getServerByKey</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$server_key</code></span>): <span class="type"><span class="type"><a href="language.types.array.php" class="type array">array</a></span>|<span class="type"><a href="language.types.singleton.php" class="type false">false</a></span></span></div>

  <p class="para rdfs-comment">
   <span class="function"><strong>Memcached::getServerByKey()</strong></span> returns the server that
   would be selected by a particular <code class="parameter">server_key</code> in all
   the <span class="function"><strong>Memcached::*ByKey()</strong></span> operations.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-memcached.getserverbykey-parameters">
  <h3 class="title">Elenco dei parametri</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">server_key</code></dt>
     <dd>
      <p class="para">
       La chiave che identifica il server su cui salvare il valore. Invece di effettuare li&#039;hashing sulla chiave dell&#039;elemento, si effettua l&#039;hashing della chiave del server al momento di decidere con quale server memcached comunicare. Questo permette di raggruppare gli elementi correlati ad un singolo server ottenendo maggiore efficienza nelle operazioni multiple.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-memcached.getserverbykey-returnvalues">
  <h3 class="title">Valori restituiti</h3>
  <p class="para">
   Returns an array containing three keys of <code class="literal">host</code>,
   <code class="literal">port</code>, and <code class="literal">weight</code> on success o <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> in caso di fallimento.
   Utilizzare <span class="methodname"><strong>Memcached:getResultCode()</strong></span> se necessario.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-memcached.getserverbykey-examples">
  <h3 class="title">Esempi</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Example #1 <span class="function"><strong>Memcached::getServerByKey()</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 /></span><span style="color: #0000BB">$m</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">addServers</span><span style="color: #007700">(array(<br />    array(</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">40</span><span style="color: #007700">),<br />    array(</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">40</span><span style="color: #007700">),<br />    array(</span><span style="color: #DD0000">'mem3.domain.com'</span><span style="color: #007700">, </span><span style="color: #0000BB">11211</span><span style="color: #007700">, </span><span style="color: #0000BB">20</span><span style="color: #007700">),<br />));<br /><br /></span><span style="color: #0000BB">$m</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">setOption</span><span style="color: #007700">(</span><span style="color: #0000BB">Memcached</span><span style="color: #007700">::</span><span style="color: #0000BB">OPT_LIBKETAMA_COMPATIBLE</span><span style="color: #007700">, </span><span style="color: #0000BB">true</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$m</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getServerByKey</span><span style="color: #007700">(</span><span style="color: #DD0000">'user'</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$m</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getServerByKey</span><span style="color: #007700">(</span><span style="color: #DD0000">'log'</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$m</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getServerByKey</span><span style="color: #007700">(</span><span style="color: #DD0000">'ip'</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

    <div class="example-contents"><p>Il precedente esempio visualizzerà
qualcosa simile a:</p></div>
    <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">array(3) {
  [&quot;host&quot;]=&gt;
  string(15) &quot;mem3.domain.com&quot;
  [&quot;port&quot;]=&gt;
  int(11211)
  [&quot;weight&quot;]=&gt;
  int(20)
}
array(3) {
  [&quot;host&quot;]=&gt;
  string(15) &quot;mem2.domain.com&quot;
  [&quot;port&quot;]=&gt;
  int(11211)
  [&quot;weight&quot;]=&gt;
  int(40)
}
array(3) {
  [&quot;host&quot;]=&gt;
  string(15) &quot;mem2.domain.com&quot;
  [&quot;port&quot;]=&gt;
  int(11211)
  [&quot;weight&quot;]=&gt;
  int(40)
}</pre>
</div>
    </div>
   </div>
  </p>
 </div>


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