<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.wincache.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'zh',
  ),
  'this' => 
  array (
    0 => 'function.wincache-ucache-cas.php',
    1 => 'wincache_ucache_cas',
    2 => 'Compares the variable with old value and assigns new value to it',
  ),
  'up' => 
  array (
    0 => 'ref.wincache.php',
    1 => 'WinCache 函数',
  ),
  'prev' => 
  array (
    0 => 'function.wincache-ucache-add.php',
    1 => 'wincache_ucache_add',
  ),
  'next' => 
  array (
    0 => 'function.wincache-ucache-clear.php',
    1 => 'wincache_ucache_clear',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/wincache/functions/wincache-ucache-cas.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.wincache-ucache-cas" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">wincache_ucache_cas</h1>
  <p class="verinfo">(PECL wincache &gt;= 1.1.0)</p><p class="refpurpose"><span class="refname">wincache_ucache_cas</span> &mdash; <span class="dc-title">
   Compares the variable with old value and assigns new value to it
  </span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.wincache-ucache-cas-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>wincache_ucache_cas</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$key</code></span>, <span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$old_value</code></span>, <span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$new_value</code></span>): <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span></div>

  <p class="para rdfs-comment">
   Compares the variable associated with the <code class="parameter">key</code> with <code class="parameter">old_value</code> 
   and if it matches then assigns the <code class="parameter">new_value</code> to it.
  </p>
 </div>

 <div class="refsect1 parameters" id="refsect1-function.wincache-ucache-cas-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">key</code></dt>
     <dd>
      <p class="para">
       The <code class="parameter">key</code> that is used to store the variable in the cache. 
       <code class="parameter">key</code> is case sensitive.
      </p>
     </dd>
    
    
     <dt><code class="parameter">old_value</code></dt>
     <dd>
      <p class="para">
       Old value of the variable pointed by <code class="parameter">key</code> in the user cache. 
       The value should be of type <code class="literal">long</code>, otherwise the function returns 
       <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>.
      </p>
     </dd>
    
    
     <dt><code class="parameter">new_value</code></dt>
     <dd>
      <p class="para">
       New value which will get assigned to variable pointer by <code class="parameter">key</code> if a 
       match is found. The value should be of type <code class="literal">long</code>, otherwise 
       the function returns <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>

 <div class="refsect1 returnvalues" id="refsect1-function.wincache-ucache-cas-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   成功时返回 <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong>， 或者在失败时返回 <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>。
  </p>
 </div>

 <div class="refsect1 examples" id="refsect1-function.wincache-ucache-cas-examples">
  <h3 class="title">示例</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>示例 #1 Using <span class="function"><strong>wincache_ucache_cas()</strong></span></strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />wincache_ucache_set</span><span style="color: #007700">(</span><span style="color: #DD0000">'counter'</span><span style="color: #007700">, </span><span style="color: #0000BB">2922</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">wincache_ucache_cas</span><span style="color: #007700">(</span><span style="color: #DD0000">'counter'</span><span style="color: #007700">, </span><span style="color: #0000BB">2922</span><span style="color: #007700">, </span><span style="color: #0000BB">1</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">wincache_ucache_get</span><span style="color: #007700">(</span><span style="color: #DD0000">'counter'</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

    <div class="example-contents"><p>以上示例会输出：</p></div>
    <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">bool(true) 
int(1)</pre>
</div>
    </div>    
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.wincache-ucache-cas-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.wincache-ucache-inc.php" class="function" rel="rdfs-seeAlso">wincache_ucache_inc()</a> - Increments the value associated with the key</span></li>
    <li><span class="function"><a href="function.wincache-ucache-dec.php" class="function" rel="rdfs-seeAlso">wincache_ucache_dec()</a> - Decrements the value associated with the key</span></li>
   </ul>
  </p>
 </div>


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