array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'uk', ), '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); ?>
(PECL wincache >= 1.1.0)
wincache_ucache_cas — Compares the variable with old value and assigns new value to it
Compares the variable associated with the key with old_value
and if it matches then assigns the new_value to it.
key
The key that is used to store the variable in the cache.
key is case sensitive.
old_value
Old value of the variable pointed by key in the user cache.
The value should be of type long, otherwise the function returns
false.
new_value
New value which will get assigned to variable pointer by key if a
match is found. The value should be of type long, otherwise
the function returns false.
Приклад #1 Using wincache_ucache_cas()
<?php
wincache_ucache_set('counter', 2922);
var_dump(wincache_ucache_cas('counter', 2922, 1));
var_dump(wincache_ucache_get('counter'));
?>Поданий вище приклад виведе:
bool(true) int(1)