apc_exists
(PECL apc >= 3.1.4)
apc_exists - 检查APC密钥是否存在
描述
mixed apc_exists ( mixed $keys )
检查是否存在一个或多个APC密钥。
参数
keys
包含键的字符串或字符串数??组。
返回值
如果键存在,则返回TRUE
;否则,FALSE
如果传递keys
数组,则返回包含所有现有键的数组,如果不存在,则返回一个空数组。
示例
Example #1 apc_exists() example
<?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)
}
See Also
- apc_cache_info() - 从APC的数据存储中检索缓存的信息
- apc_fetch() - 从缓存中获取存储的变量
← apc_delete
apc_fetch →
本文档系腾讯云开发者社区成员共同维护,如有问题请联系 cloudcommunity@tencent.com