<commit_before>Phive Queue
===========
[![Build Status](https://secure.travis-ci.org/rybakit/phive-queue.png?branch=master)](http://travis-ci.org/rybakit/phive-queue)

Phive Queue is a time-based scheduling queue with multiple backends support.


## Installation

The recommended way to install Phive Queue is through [Composer](http://getcomposer.org).

To install the library run the following command:

```sh
$ php composer.phar require rybakit/phive-queue:*
```


## Usage example

```php
<?php

use Phive\Queue\Exception\NoItemAvailableException;
use Phive\Queue\Queue\InMemoryQueue;

$queue = new InMemoryQueue();

$queue->push('item1');
$queue->push('item2', new DateTime());
$queue->push('item3', time());
$queue->push('item4', '+5 seconds');
$queue->push('item5', 'next Monday');

// get the queue size
$count = $queue->count(); // $count = 5;

// pop items off the queue
try {
    while (1) {
        $item = $queue->pop(); // $item = 'item1', 'item2', 'item3';
    }
} catch (NoItemAvailableException $e) {
    // no items are available
    ...
}

sleep(5);
$item = $queue->pop(); // $item = 'item4';

// clear the queue (will remove 'item5')
$queue->clear();
```


## Queues

Currently, there are the following queues available:

* MongoQueue
* RedisQueue
* GenericPdoQueue
* SqlitePdoQueue
* SysVQueue
* InMemoryQueue

#### MongoQueue

The MongoQueue requires the [Mongo](http://pecl.php.net/package/mongo) PECL extension (v1.3.0 or higher).

##### Parameters

> <b>client</b>   The MongoClient instance<br>
> <b>dbName</b>   The database name<br>
> <b>collName</b> The collection name<br>

##### Example

```php
<?php

use Phive\Queue\Queue\MongoQueue;

$client = new MongoClient();
$queue = new MongoQueue($client, 'my_db', 'my_coll');
```

#### RedisQueue

For the RedisQueue you have to install the [Redis](http://pecl.php.net/package/redis) PECL extension (v2.2.4 or higher).

##### Parameters

> <b>redis</b> The Redis instance<br>

##### Example

```php
<?php<commit_msg>Fix redis client version in README.md<commit_after>Phive Queue
===========
[![Build Status](https://secure.travis-ci.org/rybakit/phive-queue.png?branch=master)](http://travis-ci.org/rybakit/phive-queue)

Phive Queue is a time-based scheduling queue with multiple backends support.


## Installation

The recommended way to install Phive Queue is through [Composer](http://getcomposer.org).

To install the library run the following command:

```sh
$ php composer.phar require rybakit/phive-queue:*
```


## Usage example

```php
<?php

use Phive\Queue\Exception\NoItemAvailableException;
use Phive\Queue\Queue\InMemoryQueue;

$queue = new InMemoryQueue();

$queue->push('item1');
$queue->push('item2', new DateTime());
$queue->push('item3', time());
$queue->push('item4', '+5 seconds');
$queue->push('item5', 'next Monday');

// get the queue size
$count = $queue->count(); // $count = 5;

// pop items off the queue
try {
    while (1) {
        $item = $queue->pop(); // $item = 'item1', 'item2', 'item3';
    }
} catch (NoItemAvailableException $e) {
    // no items are available
    ...
}

sleep(5);
$item = $queue->pop(); // $item = 'item4';

// clear the queue (will remove 'item5')
$queue->clear();
```


## Queues

Currently, there are the following queues available:

* MongoQueue
* RedisQueue
* GenericPdoQueue
* SqlitePdoQueue
* SysVQueue
* InMemoryQueue

#### MongoQueue

The MongoQueue requires the [Mongo](http://pecl.php.net/package/mongo) PECL extension *(v1.3.0 or higher)*.

##### Parameters

> <b>client</b>   The MongoClient instance<br>
> <b>dbName</b>   The database name<br>
> <b>collName</b> The collection name<br>

##### Example

```php
<?php

use Phive\Queue\Queue\MongoQueue;

$client = new MongoClient();
$queue = new MongoQueue($client, 'my_db', 'my_coll');
```

#### RedisQueue

For the RedisQueue you have to install the [Redis](http://pecl.php.net/package/redis) PECL extension *(v2.2.3 or higher)*.

##### Parameters

> <b>redis</b> The Redis instance<br>

##### Example

```php
<?php
{'fraction_non_alphanumeric': 0.18329177057356608, 'fraction_numerical': 0.00997506234413965, 'mean_word_length': 4.412955465587045, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 53, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1385928', 'n_tokens_mistral': 1434, 'n_tokens_neox': 1379, 'n_words': 358}