首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

CachingIterator::getCache

(PHP 5 >= 5.2.0, PHP 7)

CachingIterator::getCache — Retrieve the contents of the cache

Description

代码语言:javascript
复制
public array CachingIterator::getCache ( void )

Retrieve the contents of the cache.

Note: The CachingIterator::FULL_CACHE flag must be being used.

Parameters

This function has no parameters.

Return Values

An array containing the cache items.

Errors/Exceptions

Throws a BadMethodCallException when the CachingIterator::FULL_CACHE flag is not being used.

Examples

Example #1 CachingIterator::getCache() example

代码语言:javascript
复制
<?php
$iterator = new ArrayIterator(array(1, 2, 3));
$cache    = new CachingIterator($iterator, CachingIterator::FULL_CACHE);

$cache->next();
$cache->next();
var_dump($cache->getCache());

$cache->next();
var_dump($cache->getCache());
?>

The above example will output:

代码语言:javascript
复制
array(2) {
  [0]=>
  int(1)
  [1]=>
  int(2)
}
array(3) {
  [0]=>
  int(1)
  [1]=>
  int(2)
  [2]=>
  int(3)
}

← CachingIterator::current

CachingIterator::getFlags →

代码语言:txt
复制
 © 1997–2017 The PHP Documentation Group

Licensed under the Creative Commons Attribution License v3.0 or later.

扫码关注腾讯云开发者

领取腾讯云代金券