Book/apcu-Phpdoc专题

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 <span class="oointerface">implements <span class="interfacename">Iterator {

/* Methods */

public <span class="methodname">__construct ([ <span class="methodparam">mixed $search<span class="initializer"> = null [, <span class="methodparam">int $format<span class="initializer"> = APC_ITER_ALL [, <span class="methodparam">int $chunk_size<span class="initializer"> = 100 [, <span class="methodparam">int $list<span class="initializer"> = APC_LIST_ACTIVE ]]]] )

public mixed current ( <span class="methodparam">void )

public int <span class="methodname">getTotalCount ( <span class="methodparam">void )

public int <span class="methodname">getTotalHits ( <span class="methodparam">void )

public int <span class="methodname">getTotalSize ( <span class="methodparam">void )

public string key ( <span class="methodparam">void )

public bool next ( <span class="methodparam">void )

public void rewind ( <span class="methodparam">void )

public bool valid ( <span class="methodparam">void )

}

APCUIterator::__construct

Constructs an APCUIterator iterator object

说明

public <span class="methodname">APCUIterator::__construct ([ <span class="methodparam">mixed $search<span class="initializer"> = null [, <span class="methodparam">int $format<span class="initializer"> = APC_ITER_ALL [, <span class="methodparam">int $chunk_size<span class="initializer"> = 100 [, <span class="methodparam">int $list<span class="initializer"> = APC_LIST_ACTIVE ]]]] )

Constructs an APCUIterator <span class="type">object.

参数

search
A PCRE regular expression that matches against APCu key names, either as a <span class="type">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 APCITER* 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 <span class="type">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 ( <span class="methodparam">void )

Gets the current item from the <span class="classname">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 <span class="methodname">APCUIterator::getTotalCount ( <span class="methodparam">void )

Get the total count.

Warning

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

参数

此函数没有参数。

返回值

The total count.

参见

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

APCUIterator::getTotalHits

Get total cache hits

说明

public int <span class="methodname">APCUIterator::getTotalHits ( <span class="methodparam">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 <span class="methodname">APCUIterator::getTotalSize ( <span class="methodparam">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 ( <span class="methodparam">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 ( <span class="methodparam">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 ( <span class="methodparam">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 ( <span class="methodparam">void )

Checks if the current iterator position is valid.

参数

此函数没有参数。

返回值

Returns true if the current iterator position is valid, otherwise false.

参见

  • APCUIterator::current
  • Iterator::valid

本站为非盈利网站,作品由网友提供上传,如无意中有侵犯您的版权,请联系删除