Since: APCu 5.0.0

class APCUIterator implements Iterator (View source)

The APCUIterator class

The APCUIterator class makes it easier to iterate over large APCu 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|string[]|null $search = null, int $format = APC_ITER_ALL, int $chunk_size = 100, int $list = APC_LIST_ACTIVE)

Constructs an APCUIterator 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 APCUIterator 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|false
getTotalSize()

Gets the total cache size

int|false
getTotalCount()

Get the total count

Details

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

Constructs an APCUIterator iterator object

Parameters

string|string[]|null $search

A PCRE regular expression that matches against APCu 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_DELETED.

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 APCUIterator 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|false getTotalSize()

Gets the total cache size

Return Value

int|false

The total cache size.

int|false getTotalCount()

Get the total count

Return Value

int|false

The total count.