Sophie

Sophie

distrib > Mageia > 4 > i586 > by-pkgid > f800694edefe91adea2624f711a41a2d > files > 9135

php-manual-en-5.5.7-1.mga4.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Changes server parameters and status at runtime</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="memcache.setcompressthreshold.html">Memcache::setCompressThreshold</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="ref.memcache.html">Memcache Functions</a></div>
 <div class="up"><a href="class.memcache.html">Memcache</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="memcache.setserverparams" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">Memcache::setServerParams</h1>
  <p class="verinfo">(PECL memcache &gt;= 2.1.0)</p><p class="refpurpose"><span class="refname">Memcache::setServerParams</span> &mdash; <span class="dc-title">Changes server parameters and status at runtime</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-memcache.setserverparams-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">bool</span> <span class="methodname"><strong>Memcache::setServerParams</strong></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$host</code></span>
   [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$port</code><span class="initializer"> = 11211</span></span>
   [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$timeout</code></span>
   [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$retry_interval</code><span class="initializer"> = false</span></span>
   [, <span class="methodparam"><span class="type">bool</span> <code class="parameter">$status</code></span>
   [, <span class="methodparam"><span class="type"><a href="language.types.callable.html" class="type callable">callable</a></span> <code class="parameter">$failure_callback</code></span>
  ]]]]] )</div>

  
  <p class="para rdfs-comment">
    <span class="function"><strong>Memcache::setServerParams()</strong></span> changes server parameters at runtime.
   You can also use the  <span class="function"><strong>memcache_set_server_params()</strong></span> function.
  </p>
  
  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <p class="para">
    This function has been added to Memcache version 2.1.0.
   </p>
  </p></blockquote>

 </div>


 <div class="refsect1 parameters" id="refsect1-memcache.setserverparams-parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   <dl>

    <dt>

     <span class="term"><em><code class="parameter">host</code></em></span>
     <dd>

      <p class="para">
       Point to the host where memcached is listening for connections.
      </p>
     </dd>

    </dt>

    <dt>

     <span class="term"><em><code class="parameter">port</code></em></span>
     <dd>

      <p class="para">
       Point to the port where memcached is listening for connections.
      </p>
     </dd>

    </dt>

    <dt>

     <span class="term"><em><code class="parameter">timeout</code></em></span>
     <dd>

      <p class="para">
       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.
      </p>
     </dd>

    </dt>

    <dt>

     <span class="term"><em><code class="parameter">retry_interval</code></em></span>
     <dd>

      <p class="para">
       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 <em><code class="parameter">persistent</code></em> parameter has any 
       effect when the extension is loaded dynamically via  <span class="function"><a href="function.dl.html" class="function">dl()</a></span>.
      </p>
     </dd>

    </dt>

    <dt>

     <span class="term"><em><code class="parameter">status</code></em></span>
     <dd>

      <p class="para">
       Controls if the server should be flagged as online. Setting this parameter
       to <strong><code>FALSE</code></strong> and <em><code class="parameter">retry_interval</code></em> to -1 allows a failed 
       server to be kept in the pool so as not to affect the key distribution 
       algoritm. Requests for this server will then failover or fail immediately 
       depending on the <em><code class="parameter">memcache.allow_failover</code></em> setting.
       Default to <strong><code>TRUE</code></strong>, meaning the server should be considered online.
      </p>
     </dd>

    </dt>

    <dt>

     <span class="term"><em><code class="parameter">failure_callback</code></em></span>
     <dd>

      <p class="para">
       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.
      </p>
     </dd>

    </dt>

   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-memcache.setserverparams-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns <strong><code>TRUE</code></strong> on success or <strong><code>FALSE</code></strong> on failure.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-memcache.setserverparams-examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   <div class="example" id="example-4425">
    <p><strong>Example #1  <span class="function"><strong>Memcache::setServerParams()</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: #007700">function&nbsp;</span><span style="color: #0000BB">_callback_memcache_failure</span><span style="color: #007700">(</span><span style="color: #0000BB">$host</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$port</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;print&nbsp;</span><span style="color: #DD0000">"memcache&nbsp;'</span><span style="color: #0000BB">$host</span><span style="color: #DD0000">:</span><span style="color: #0000BB">$port</span><span style="color: #DD0000">'&nbsp;failed"</span><span style="color: #007700">;<br />}<br /><br /></span><span style="color: #FF8000">/*&nbsp;OO&nbsp;API&nbsp;*/<br /><br /></span><span style="color: #0000BB">$memcache&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">Memcache</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">//&nbsp;Add&nbsp;the&nbsp;server&nbsp;in&nbsp;offline&nbsp;mode<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">,&nbsp;</span><span style="color: #0000BB">11211</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">false</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">1</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">1</span><span style="color: #007700">,&nbsp;-</span><span style="color: #0000BB">1</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">false</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;Bring&nbsp;the&nbsp;server&nbsp;back&nbsp;online<br /></span><span style="color: #0000BB">$memcache</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">setServerParams</span><span style="color: #007700">(</span><span style="color: #DD0000">'memcache_host'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">11211</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">1</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">15</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">true</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'_callback_memcache_failure'</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/*&nbsp;procedural&nbsp;API&nbsp;*/<br /><br /></span><span style="color: #0000BB">$memcache_obj&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">memcache_connect</span><span style="color: #007700">(</span><span style="color: #DD0000">'memcache_host'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">11211</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">memcache_set_server_params</span><span style="color: #007700">(</span><span style="color: #0000BB">$memcache_obj</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'memcache_host'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">11211</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">1</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">15</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">true</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'_callback_memcache_failure'</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

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


 <div class="refsect1 seealso" id="refsect1-memcache.setserverparams-seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"> <span class="function"><a href="memcache.addserver.html" class="function" rel="rdfs-seeAlso">Memcache::addServer()</a> - Add a memcached server to connection pool</span></li>
    <li class="member"> <span class="function"><a href="memcache.getserverstatus.html" class="function" rel="rdfs-seeAlso">Memcache::getServerStatus()</a> - Returns server status</span></li>
   </ul>
  </p>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="memcache.setcompressthreshold.html">Memcache::setCompressThreshold</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="ref.memcache.html">Memcache Functions</a></div>
 <div class="up"><a href="class.memcache.html">Memcache</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>