With MAMP (using PHP 5.3.5 and APC 3.1.7) passing an array with multiple regex strings as $search arg always yields an empty APCIterator. Whereas passing a single string regex works. (Note: I only tried cache type 'user'.)
Workaround: Concatenated all regexes to single one with alternation. Example:
<?php
$results = new APCIterator('user', '/^('.implode('|', $patterns).')');
?>
APCIterator::__construct
(PECL apc >= 3.1.1)
APCIterator::__construct — APCIterator イテレータオブジェクトを作成する
説明
public APCIterator::__construct
( string
$cache
[, mixed $search = null
[, int $format
[, int $chunk_size = 100
[, int $list
]]]] )APCIterator オブジェクトを作成します。
パラメータ
-
cache -
キャッシュの形式。user あるいは file となります。
-
search -
APC のキーの名前にマッチする PCRE 正規表現。 単一の正規表現の場合は文字列で、複数の正規表現の場合は配列で指定します。
NULLを渡すと、検索をスキップします。 -
format -
希望する書式。 APC_ITER_* 定数の組み合わせで指定します。
-
chunk_size -
チャンクサイズ。0 より大きい値でなければなりません。 デフォルト値は 100 です。
-
list -
一覧にする形式。
APC_LIST_ACTIVEあるいはAPC_LIST_DELETEDを渡します。
返り値
成功した場合に APCIterator オブジェクト、
失敗した場合に NULL を返します。
例
例1 APCIterator::__construct() の例
<?php
foreach (new APCIterator('user', '/^counter\./') as $counter) {
echo "$counter[key]: $counter[value]\n";
apc_dec($counter['key'], $counter['value']);
}
?>
参考
- apc_exists() - APC キーが存在するかどうかを調べる
- apc_cache_info() - APC のデータから、キャッシュされた情報を取得する
petabyte
10-Aug-2011 03:38
rodney dot rehm at medialize dot de
30-Jun-2011 12:29
new APCIterator('file'); only lists the files loaded within the current process-scope. It is thus not possible to check if a given file already resides in the op-code cache.
(PHP5.3.6 APC3.1.9)
Anti Veeranna
27-Oct-2010 09:46
Iterating (and specifically using current()) does not expunge cache entries for which $ttl has passed, you need to use apc_fetch to get rid of stale entries.
