apcu_exists
(PECL apcu >= 4.0.0)
apcu_exists - 항목이 있는지 확인
설명
apcu_exists(mixed $keys
): mixed
하나 이상의 APCu 항목이 있는지 확인합니다.
매개변수
keys
- 키를 포함하는 문자열 또는 문자열 배열입니다.
반환 값
키가 있으면 true
를 반환하고 그렇지 않으면 false
를 반환합니다. 또는 배열이 키에 전달된 경우 모든 기존 keys
를 포함하는 배열이 반환되고, 존재하지 않는 경우 빈 배열이 반환됩니다.
Examples
예제 #1 apcu_exists() 예제
<?php
$fruit = 'apple';
$veggie = 'carrot';
apcu_store('foo', $fruit);
apcu_store('bar', $veggie);
if (apcu_exists('foo')) {
echo "Foo exists: ";
echo apcu_fetch('foo');
} else {
echo "Foo does not exist";
}
echo PHP_EOL;
if (apcu_exists('baz')) {
echo "Baz exists.";
} else {
echo "Baz does not exist";
}
echo PHP_EOL;
$ret = apcu_exists(array('foo', 'donotexist', 'bar'));
var_dump($ret);
?>
위의 예는 다음과 유사한 결과를 출력합니다.
Foo exists: apple Baz does not exist array(2) { ["foo"]=> bool(true) ["bar"]=> bool(true) }
기타
- apcu_cache_info() - APCu의 데이터 저장소에서 캐시된 정보 검색
- apcu_fetch() - 캐시에서 저장된 변수 가져오기