PHP Iterating over Entries


Example

The APCUIterator allows to iterate over entries in the cache:

foreach (new APCUIterator() as $entry) {
    print_r($entry);
}

The iterator can be initialized with an optional regular expression to select only entries with matching keys:

foreach (new APCUIterator($regex) as $entry) {
    print_r($entry);
}

Information about a single cache entry can be obtained via:

$key = '…';
$regex = '(^' . preg_quote($key) . '$)';
print_r((new APCUIterator($regex))->current());