class APCIterator implements Iterator (View source)

The APCIterator class

The APCIterator class makes it easier to iterate over large APC caches. This is helpful as it allows iterating over large caches in steps, while grabbing a defined number of entries per lock instance, so it frees the cache locks for other activities rather than hold up the entire cache to grab 100 (the default) entries. Also, using regular expression matching is more efficient as it's been moved to the C level.

Methods

__construct(string $cache, string|string[]|null $search = null, int $format = APC_ITER_ALL, int $chunk_size = 100, int $list = APC_LIST_ACTIVE)

Constructs an APCIterator iterator object

void
rewind()

Rewinds back the iterator to the first element

bool
valid()

Checks if the current iterator position is valid

mixed
current()

Gets the current item from the APCIterator stack

mixed
key()

Gets the current iterator key

void
next()

Moves the iterator pointer to the next element

int|false
getTotalHits()

Gets the total number of cache hits

int|bool
getTotalSize()

Gets the total cache size

int|bool
getTotalCount()

Get the total count

Details

__construct(string $cache, string|string[]|null $search = null, int $format = APC_ITER_ALL, int $chunk_size = 100, int $list = APC_LIST_ACTIVE)

Constructs an APCIterator iterator object

Parameters

string $cache

The cache type, which will be 'user' or 'file'.

string|string[]|null $search

A PCRE regular expression that matches against APC key names, either as a string for a single regular expression, or as an array of regular expressions. Or, optionally pass in NULL to skip the search.

int $format

The desired format, as configured with one ore more of the APCITER* constants.

int $chunk_size

The chunk size. Must be a value greater than 0. The default value is 100.

int $list

The type to list. Either pass in APC_LIST_ACTIVE or APC_LIST_INACTIVE.

void rewind()

Rewinds back the iterator to the first element

Return Value

void

Any returned value is ignored.

bool valid()

Checks if the current iterator position is valid

Return Value

bool

The return value will be casted to boolean and then evaluated. Returns true on success or false on failure.

mixed current()

Gets the current item from the APCIterator stack

Return Value

mixed

Can return any type.

mixed key()

Gets the current iterator key

Return Value

mixed

TKey on success, or null on failure.

void next()

Moves the iterator pointer to the next element

Return Value

void

Any returned value is ignored.

int|false getTotalHits()

Gets the total number of cache hits

Return Value

int|false

The number of hits on success, or FALSE on failure.

int|bool getTotalSize()

Gets the total cache size

Return Value

int|bool

The total cache size.

int|bool getTotalCount()

Get the total count

Return Value

int|bool

The total count.