(PECL apc >= 3.1.1)
APCIterator::__construct — 构造一个 APCIterator 迭代器对象
$cache
[, mixed $search
= null
[, int $format
[, int $chunk_size
= 100
[, int $list
]]]] )构造一个 APCIterator object.
cache
缓存类型,可以是 user 或者 file。
search
匹配 APC 键名的 PCRE 正则表达式,既可以是单个正则表达式 string,也可以是 array 的正则表达式。或者可以是 NULL
来略过搜索。
format
需要的格式可以用一个或多个 APC_ITER_* 常量。
chunk_size
块的大小。必须是一个大于0的值,默认是100。
list
需要列出的类型。可以是 APC_LIST_ACTIVE
或 APC_LIST_DELETED
。
成功时返回 APCIterator object,失败时返回 NULL
。
Example #1 A APCIterator::__construct() example
<?php
foreach (new APCIterator('user', '/^counter\./') as $counter) {
echo "$counter[key]: $counter[value]\n";
apc_dec($counter['key'], $counter['value']);
}
?>
petabyte (2011-08-10 06:38:15)
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).')');
?>
rodney dot rehm at medialize dot de (2011-06-29 15:29:33)
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 (2010-10-27 12:46:49)
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.