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;
}
}
?>
apc_exists
(PECL apc >= 3.1.4)
apc_exists — APC キーが存在するかどうかを調べる
パラメータ
-
keys -
キーを含む文字列、あるいは文字列の配列。
返り値
キーが存在する場合に TRUE、それ以外の場合に FALSE を返します。
keys に配列を渡したときは、
存在するキーをすべて含む配列を返します。
どれも存在しない場合は空の配列を返します。
例
例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() - APC のデータから、キャッシュされた情報を取得する
- apc_fetch() - 格納されている変数をキャッシュから取得する
FiFFiO
24-May-2012 08:13
