导航首页 » 技术教程 » PHP APC函数:apc_exists()的用法
PHP APC函数:apc_exists()的用法 146 2023-12-15   

apc_exists

(PECL apc >= 3.1.4)

apc_exists — 检查APC中是否存在某个或者某些key

说明

mixed apc_exists ( mixed $keys )

检查是否有一个或者多个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 store apc_fetch() - 从缓存中取出存储的变量

!!!站长长期在线接!!!

网站、小程序:定制开发/二次开发/仿制开发等

各种疑难杂症解决/定制接口/定制采集等

站长微信:lxwl520520

站长QQ:1737366103