apc_exists()
(PECL apc >= 3.1.4)
检查APC中是否存在某个或者某些key
说明
apc_exists(mixed $keys): mixed
检查是否有一个或者多个APC键名存在
参数
- $keys
string,或者包含键的array,元素是字符串。
返回值
如果Key存在的话返回TRUE, 否则返回FALSE如果参数$keys是一个array,将返回一个包含所有存在的key的数组,假如数组中的key一个都不存在的话,就返回空的数组。
范例
Example #1 apc_exists()例子
<?php
$fruit = 'apple';
$veggie = 'carrot';
apc_store('foo', $fruit);
apc_store('bar', $veggie);
if (apc_exists('foo')) {
echo "Foo exists: ";
echo apc_fetch('foo');
} else {
echo "Foo does not exist";
}
echo PHP_EOL;
if (apc_exists('baz')) {
echo "Baz exists.";
} else {
echo "Baz does not exist";
}
echo PHP_EOL;
$ret = apc_exists(array('foo', 'donotexist', 'bar'));
var_dump($ret);
?>
以上例程的输出类似于:
Foo exists: apple
Baz does not exist
array(2) {
["foo"]=>
bool(true)
["bar"]=>
bool(true)
}
参见
apc_cache_info()Retrieves cached information from APC's data storeapc_fetch()从缓存中取出存储的变量
apc_exists declaration if your PECL apc version is less than 3.1.4:
<?php
if(!function_exists('apc_exists'))
{
function apc_exists($keys)
{
$result;
apc_fetch($keys, $result);
return $result;
}
}
?>
