APC User Cache

目录

简介

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.

类摘要

APCUIterator

class APCUIterator implements Iterator {

/* Methods */

public __construct ([ mixed $search = NULL [, int $format = APC_ITER_ALL [, int $chunk_size = 100 [, int $list = APC_LIST_ACTIVE ]]]] )

public mixed current ( void )

public int getTotalCount ( void )

public int getTotalHits ( void )

public int getTotalSize ( void )

public string key ( void )

public bool next ( void )

public void rewind ( void )

public bool valid ( void )

}

APCUIterator::__construct

Constructs an APCUIterator iterator object

说明

public APCUIterator::__construct ([ mixed $search = NULL [, int $format = APC_ITER_ALL [, int $chunk_size = 100 [, int $list = APC_LIST_ACTIVE ]]]] )

Constructs an APCUIterator object.

参数

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.

format
The desired format, as configured with one or more of the APC_ITER_* constants.

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

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

返回值

An APCUIterator object on success, or NULL on failure.

范例

示例 #1 A APCUIterator::__construct example

<?php
foreach (new APCUIterator('/^counter\./') as $counter) {
    echo "$counter[key]: $counter[value]\n";
    apc_dec($counter['key'], $counter['value']);
}
?>

参见

  • apcu_exists
  • apcu_cache_info

APCUIterator::current

Get current item

说明

public mixed APCUIterator::current ( void )

Gets the current item from the APCUIterator stack.

参数

此函数没有参数。

返回值

Returns the current item on success, or FALSE if no more items or exist, or on failure.

参见

  • APCUIterator::next
  • Iterator::current

APCUIterator::getTotalCount

Get total count

说明

public int APCUIterator::getTotalCount ( void )

Get the total count.

Warning

本函数还未编写文档,仅有参数列表。

参数

此函数没有参数。

返回值

The total count.

参见

  • APCUIterator::getTotalHits
  • APCUIterator::getTotalSize
  • apcu_cache_info

APCUIterator::getTotalHits

Get total cache hits

说明

public int APCUIterator::getTotalHits ( void )

Gets the total number of cache hits.

Warning

本函数还未编写文档,仅有参数列表。

参数

此函数没有参数。

返回值

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

参见

  • APCUIterator::getTotalCount
  • APCUIterator::getTotalSize
  • apcu_cache_info

APCUIterator::getTotalSize

Get total cache size

说明

public int APCUIterator::getTotalSize ( void )

Gets the total cache size.

Warning

本函数还未编写文档,仅有参数列表。

参数

此函数没有参数。

返回值

The total cache size.

参见

  • APCUIterator::getTotalCount
  • APCUIterator::getTotalHits
  • apc_cache_info

APCUIterator::key

Get iterator key

说明

public string APCUIterator::key ( void )

Gets the current iterator key.

参数

此函数没有参数。

返回值

Returns the key on success, or FALSE upon failure.

参见

  • APCUIterator::current
  • Iterator::key

APCUIterator::next

Move pointer to next item

说明

public bool APCUIterator::next ( void )

Moves the iterator pointer to the next element.

参数

此函数没有参数。

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

参见

  • APCUIterator::current
  • APCUIterator::rewind
  • Iterator::next

APCUIterator::rewind

Rewinds iterator

说明

public void APCUIterator::rewind ( void )

Rewinds back the iterator to the first element.

参数

此函数没有参数。

返回值

没有返回值。

参见

  • APCUIterator::next
  • Iterator::next

APCUIterator::valid

Checks if current position is valid

说明

public bool APCUIterator::valid ( void )

Checks if the current iterator position is valid.

参数

此函数没有参数。

返回值

Returns TRUE if the current iterator position is valid, otherwise FALSE.

参见

  • APCUIterator::current
  • Iterator::valid