Download the PHP package mahmud/buffered-queue without Composer
On this page you can find all versions of the php package mahmud/buffered-queue. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mahmud/buffered-queue
More information about mahmud/buffered-queue
Files in mahmud/buffered-queue
Package buffered-queue
Short Description A simple to use buffering queue as PHP package (no dependencies), which flexibly buffers objects, strings, integers etc. until a maximum size is reached
License MIT
Informations about the package buffered-queue
Buffered Queue
A simple to use buffering queue as PHP package (no dependencies), which flexibly buffers objects, strings, integers etc. until a maximum size is reached
Installation
Via Composer
composer require mahmud/buffered-queue
Usage
Basic usage
Also instance of Mahmud\BufferedQueue\HandlerContract
can be passed.
API
make($key, $callback, $max_size)
-
$key
is a unique string. For duplicated key this will return same instance. $callback
will receive array of items.$max_size
determines the maximum size of the queue. When queue is full, callback is triggered with the buffered items.
push($item)
$item
can be anything. object, string, integer, boolean, array etc...
finish()
Trigger callback with buffered items at any time. Generally used after pushing all items.
run()
Force to run the callback with buffered items at any time. After running the callback buffer will be empty.
getItems()
Get all items in buffer.
Testing
vendor/bin/phpunit
License
MIT license. Please see the license file for more information.