4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\Intl\ResourceBundle\Reader
;
14 use Symfony\Component\Intl\ResourceBundle\Util\RingBuffer
;
17 * @author Bernhard Schussek <bschussek@gmail.com>
19 class BufferedBundleReader
implements BundleReaderInterface
22 * @var BundleReaderInterface
29 * Buffers a given reader.
31 * @param BundleReaderInterface $reader The reader to buffer.
32 * @param integer $bufferSize The number of entries to store
35 public function __construct(BundleReaderInterface
$reader, $bufferSize)
37 $this->reader
= $reader;
38 $this->buffer
= new RingBuffer($bufferSize);
44 public function read($path, $locale)
46 $hash = $path . '//' . $locale;
48 if (!isset($this->buffer
[$hash])) {
49 $this->buffer
[$hash] = $this->reader
->read($path, $locale);
52 return $this->buffer
[$hash];
58 public function getLocales($path)
60 return $this->reader
->getLocales($path);