Source of file ApcIterator.php
Size: 3,170 Bytes - Last Modified: 2014-03-12T23:21:18+01:00
/home/theseer/Downloads/ZendFramework-2.3.0/library/Zend/Cache/Storage/Adapter/ApcIterator.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159 | <?php /** * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace Zend\Cache\Storage\Adapter; use APCIterator as BaseApcIterator; use Zend\Cache\Storage\IteratorInterface; class ApcIterator implements IteratorInterface { /** * The apc storage instance * * @var Apc */ protected $storage; /** * The iterator mode * * @var int */ protected $mode = IteratorInterface::CURRENT_AS_KEY; /** * The base APCIterator instance * * @var BaseApcIterator */ protected $baseIterator; /** * The length of the namespace prefix * * @var int */ protected $prefixLength; /** * Constructor * * @param Apc $storage * @param BaseApcIterator $baseIterator * @param string $prefix */ public function __construct(Apc $storage, BaseApcIterator $baseIterator, $prefix) { $this->storage = $storage; $this->baseIterator = $baseIterator; $this->prefixLength = strlen($prefix); } /** * Get storage instance * * @return Apc */ public function getStorage() { return $this->storage; } /** * Get iterator mode * * @return int Value of IteratorInterface::CURRENT_AS_* */ public function getMode() { return $this->mode; } /** * Set iterator mode * * @param int $mode * @return ApcIterator Fluent interface */ public function setMode($mode) { $this->mode = (int) $mode; return $this; } /* Iterator */ /** * Get current key, value or metadata. * * @return mixed */ public function current() { if ($this->mode == IteratorInterface::CURRENT_AS_SELF) { return $this; } $key = $this->key(); if ($this->mode == IteratorInterface::CURRENT_AS_VALUE) { return $this->storage->getItem($key); } elseif ($this->mode == IteratorInterface::CURRENT_AS_METADATA) { return $this->storage->getMetadata($key); } return $key; } /** * Get current key * * @return string */ public function key() { $key = $this->baseIterator->key(); // remove namespace prefix return substr($key, $this->prefixLength); } /** * Move forward to next element * * @return void */ public function next() { $this->baseIterator->next(); } /** * Checks if current position is valid * * @return bool */ public function valid() { return $this->baseIterator->valid(); } /** * Rewind the Iterator to the first element. * * @return void */ public function rewind() { return $this->baseIterator->rewind(); } } |