gacek85/collection-iterator
Composer 安装命令:
composer require gacek85/collection-iterator
包简介
Helps iterating big sets of data
README 文档
README
#Collection Iterator
An implementation of SPL's Iterator for traversing large collections of data minimising the risk of memory limit exhaustion. Consists of an iterator service class Gacek85\Collection\CollectionIterator and an interface Gacek85\Collection\IterableDataProvider for a provider that will be providing chunks of data to the iterator service.
##How it works
The iterator loads the data using the provider chunk by chunk, previously loaded data are wiped out of the memory by the garbage collector.
##Public API
###CollectionIterator
setPerPage(int $perPage): CollectionIterator // Sets the number of items loaded at once count(): int // Returns the total count of the elements that will be traversed
Other public methods are Iterator specific API.
###IterableDataProvider
getTotal(): int // Returns the total count of available elements getChunk(int $offset, int $limit): array|Iterator //Returns the chunk of data from given offset limited with given limit
##Usage
<?php $provider = new \My\Provider(); // An implementation of Gacek85\Collection\IterableDataProvider $iterator = new \Gacek85\Collection\CollectionIterator($provider); foreach ($iterator as $k => $item) { // Do your stuff here with the item }
统计信息
- 总下载量: 21
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2016-09-29