首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

apc_exists

(PECL apc >= 3.1.4)

apc_exists - 检查APC密钥是否存在

描述

代码语言:javascript
复制
mixed apc_exists ( mixed $keys )

检查是否存在一个或多个APC密钥。

参数

keys

包含键的字符串或字符串数??组。

返回值

如果键存在,则返回TRUE;否则,FALSE如果传递keys数组,则返回包含所有现有键的数组,如果不存在,则返回一个空数组。

示例

Example #1 apc_exists() example

代码语言:javascript
复制
<?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);

?>

上面的例子会输出类似于:

代码语言:javascript
复制
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 →

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com