CakeFest 2024: The Official CakePHP Conference

apcu_fetch

(PECL apcu >= 4.0.0)

apcu_fetch 格納されている変数をキャッシュから取得する

説明

apcu_fetch(mixed $key, bool &$success = ?): mixed

エントリをキャッシュから取得します。

パラメータ

key

(apcu_store() を用いて) 値を格納する際に使用された key。 配列を渡した場合は、各要素について取得した値を返します。

success

成功した場合に true、失敗した際に false が設定されます。

戻り値

成功した場合に格納されていた変数 (あるいは配列)、失敗した場合に false を返します。

変更履歴

バージョン 説明
PECL apcu 3.0.17 success パラメータが追加されました。

例1 apcu_fetch() の例

<?php
$bar
= 'BAR';
apcu_store('foo', $bar);
var_dump(apcu_fetch('foo'));
?>

上の例の出力は以下となります。

string(3) "BAR"

参考

add a note

User Contributed Notes 1 note

up
0
orlando at thoeny dot dev
11 months ago
Note that $success is set to false if no cached entry with given key exists.
So "failure" tells you if the cache was hit or not.
To Top