Sophie

Sophie

distrib > Mageia > 7 > x86_64 > by-pkgid > 2b917e0437961edec048f1d15e2d7449 > files > 9658

php-manual-en-7.2.11-1.mga7.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>Retrieve an item</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="memcached.flush.html">Memcached::flush</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="memcached.getallkeys.html">Memcached::getAllKeys</a></div>
 <div class="up"><a href="class.memcached.html">Memcached</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="memcached.get" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">Memcached::get</h1>
  <p class="verinfo">(PECL memcached &gt;= 0.1.0)</p><p class="refpurpose"><span class="refname">Memcached::get</span> &mdash; <span class="dc-title">Retrieve an item</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-memcached.get-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <span class="methodname"><strong>Memcached::get</strong></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$key</code></span>
   [, <span class="methodparam"><span class="type"><a href="language.types.callable.html" class="type callable">callable</a></span> <code class="parameter">$cache_cb</code></span>
   [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$$flags</code></span>
  ]] )</div>

  <p class="para rdfs-comment">
   <span class="function"><strong>Memcached::get()</strong></span> returns the item that was previously
   stored under the <code class="parameter">key</code>. If the item is found and
   the <code class="parameter">flags</code> is given <strong><code>Memcached::GET_EXTENDED</code></strong>,
   it will also return the CAS token value for the item. See
   <span class="methodname"><a href="memcached.cas.html" class="methodname">Memcached::cas()</a></span> for how to use CAS tokens. <a href="memcached.callbacks.html" class="link">Read-through caching callback</a> may be
   specified via <code class="parameter">cache_cb</code> parameter.
  </p>
  <p class="para">
  </p>
 </div>


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

    
     <dt>
<code class="parameter">key</code></dt>

     <dd>

      <p class="para">
       The key of the item to retrieve.
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">cache_cb</code></dt>

     <dd>

      <p class="para">
       Read-through caching callback or <strong><code>NULL</code></strong>.
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">flags</code></dt>

     <dd>

      <p class="para">
       Flags to control the returned result. When <strong><code>Memcached::GET_EXTENDED</code></strong>
       is given, the function will also return the CAS token.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-memcached.get-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns the value stored in the cache or <strong><code>FALSE</code></strong> otherwise.
   If the <code class="parameter">flags</code> is set to <strong><code>Memcached::GET_EXTENDED</code></strong>,
   an array containing the value and the CAS token is returned instead of only the value.
   The <span class="methodname"><a href="memcached.getresultcode.html" class="methodname">Memcached::getResultCode()</a></span> will return
   <strong><code>Memcached::RES_NOTFOUND</code></strong> if the key does not exist.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-memcached.get-examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   <div class="example" id="example-5572">
    <p><strong>Example #1 <span class="function"><strong>Memcached::get()</strong></span> example #1</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$m&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</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">addServer</span><span style="color: #007700">(</span><span style="color: #DD0000">'localhost'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">11211</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$m</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">set</span><span style="color: #007700">(</span><span style="color: #DD0000">'foo'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">100</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">get</span><span style="color: #007700">(</span><span style="color: #DD0000">'foo'</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>The above example will output:</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
int(100)
</pre></div>
    </div>
   </div>
   <div class="example" id="example-5573">
    <p><strong>Example #2 <span class="function"><strong>Memcached::get()</strong></span> example #2</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$m&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</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">addServer</span><span style="color: #007700">(</span><span style="color: #DD0000">'localhost'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">11211</span><span style="color: #007700">);<br /><br />if&nbsp;(!(</span><span style="color: #0000BB">$ip&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$m</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">get</span><span style="color: #007700">(</span><span style="color: #DD0000">'ip_block'</span><span style="color: #007700">)))&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(</span><span style="color: #0000BB">$m</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getResultCode</span><span style="color: #007700">()&nbsp;==&nbsp;</span><span style="color: #0000BB">Memcached</span><span style="color: #007700">::</span><span style="color: #0000BB">RES_NOTFOUND</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$ip&nbsp;</span><span style="color: #007700">=&nbsp;array();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$m</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">set</span><span style="color: #007700">(</span><span style="color: #DD0000">'ip_block'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$ip</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;else&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">/*&nbsp;log&nbsp;error&nbsp;*/<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/*&nbsp;...&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*/<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">}<br />}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

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


 <div class="refsect1 changelog" id="refsect1-memcached.get-changelog">
  <h3 class="title">Changelog</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>Version</th>
      <th>Description</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>3.0.0</td>
      <td>
       The <code class="parameter reference">&cas_token</code> parameter was removed.
       Instead <code class="parameter">flags</code> was added and when it is given the value of <strong><code>Memcached::GET_EXTENDED</code></strong> it will ensure the CAS token to be fetched.
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 seealso" id="refsect1-memcached.get-seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="methodname"><a href="memcached.getbykey.html" class="methodname" rel="rdfs-seeAlso">Memcached::getByKey()</a> - Retrieve an item from a specific server</span></li>
    <li class="member"><span class="methodname"><a href="memcached.getmulti.html" class="methodname" rel="rdfs-seeAlso">Memcached::getMulti()</a> - Retrieve multiple items</span></li>
    <li class="member"><span class="methodname"><a href="memcached.getdelayed.html" class="methodname" rel="rdfs-seeAlso">Memcached::getDelayed()</a> - Request multiple items</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="memcached.flush.html">Memcached::flush</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="memcached.getallkeys.html">Memcached::getAllKeys</a></div>
 <div class="up"><a href="class.memcached.html">Memcached</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>