Download the PHP package jeroen-de-dauw/batching-iterator without Composer
On this page you can find all versions of the php package jeroen-de-dauw/batching-iterator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download jeroen-de-dauw/batching-iterator
More information about jeroen-de-dauw/batching-iterator
Files in jeroen-de-dauw/batching-iterator
Package batching-iterator
Short Description Iterator that fetches values in batch
License GPL-2.0+
Homepage https://github.com/JeroenDeDauw/BatchingIterator
Informations about the package batching-iterator
BatchingIterator
Small library providing an Iterator that batches requests for additional values.
This is useful as a foundation for iterators over data that is in an expensive to
access location, such as a database or a web API.
Class overview
Core interface:
BatchingIterator- iterator that batches requests via aBatchingFetcherBatchingFetcher- interface withfetchNextmethod. You will likely need to create an implementation
Utilities:
MultipleBatchingFetcher- combines a number ofBatchingFetcherinstances into oneInMemoryBatchingFetcher- adapts anarrayto theBatchingFetcherinterfaceIteratorBasedBatchingFetcher- adapts anIteratorto theBatchingFetcherinterface
Usage
Create a service that uses an Iterator.
Note how this service only depends on Iterator. It is not aware of how the Iterator provides its
results. You thus decoupled the service from who retrieves the results, and from when this happens.
They could be coming from values already in memory, wrapped in an ArrayIterator, or be pulled from
a web service as iteration happens. Using an ArrayIterator is very helpful for testing.
Implement the BatchingFetcher interface. If you already have a service to retrieve the data, this
can be a simple wrapper.
Now you can easily instantiate the service, have the batching optimization, and have all responsibilities nicely decoupled.
Installation
You can use Composer to download and install this package as well as its dependencies.
To add this package as a local, per-project dependency to your project, simply add a
dependency on jeroen/batching-iterator to your project's composer.json file.
Here is a minimal example of a composer.json file that just defines a dependency on
BatchingIterator 3.x:
Release notes
Version 3.0.0 (2017-05-16)
- Dropped support for PHP 5.x
- Added scalar and return type hints
Version 2.1.2 (2014-11-02)
- The max batch size in
BatchingIteratornow defaults to 10, avoiding usage of the iterator without this value being set.
Version 2.1.1 (2014-08-19)
- Release with package name
jeroen/batching-iteratorinstead ofjeroen-de-dauw/batching-iterator.
Version 2.1 (2014-07-19)
MultipleBatchingFetchernow accepts an array ofBatchingFetcherin its constructor
Version 2.0 (2014-07-19)
Breaking changes:
- Added
rewindmethod to theBatchingFetcherinterface - Renamed
BatchingIterator\InMemoryBatchingFetchertoBatchingIterator\Fetchers\InMemoryBatchingFetcher
New features and enhancements:
BatchingIteratorcan now be iterated over multiple times- Added
MultipleBatchingFetcher - Added
IteratorBasedBatchingFetcher
Version 1.0 (2014-07-03)
Initial release with
BatchingIteratorclassBatchingFetcherinterfaceInMemoryBatchingFetchertrivial implementation ofBatchingFetcher




