2017 © Pedro Peláez
 

library ugly-queue

A simple file-based queue system for PHP 5.3.3+

image

dcarbone/ugly-queue

A simple file-based queue system for PHP 5.3.3+

  • Tuesday, October 13, 2015
  • by dcarbone
  • Repository
  • 1 Watchers
  • 0 Stars
  • 10 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 8 Versions
  • 0 % Grown

The README.md

ugly-queue

A simple file-based FIFO queue system for PHP 5.3.3+, (*1)

Build status: Build Status, (*2)

Installation

This library is designed to be installed into your app using https://getcomposer.org/. Simply copy-paste the following line into your "requires:" hash:, (*3)

"dcarbone/ugly-queue": "0.4.*"

Basic Usage

Once installed, you must first initialize an instance of src/UglyQueueManager.php. This is done as such:, (*4)

$queueBaseDir = 'path to where you would like queue files and directories to be stored';

$manager = new UglyQueueManager($queueBaseDir);

Once initialized, you can start adding queues!, (*5)

$sandwichQueue = $manager->createQueue('sandwiches');

$sandwichQueue->lock();

$sandwichQueue->addItems(array(
    'bread',
    'meat',
    'cheese',
    'lettuce',
    'bread'
));

$sandwichQueue->unlock();

Once you have items added to the queue, you can either pull items out ad-hoc or set up some sort of cron or schedule task to process items regularly., (*6)

If the base directory for all of your queues remains the same, each initialization of UglyQueueManager will automatically find and initialize instances of pre-existing UglyQueues., (*7)

In a subsequent request, simply do the following:, (*8)

$queueBaseDir = 'path to where you would like queue files and directories to be stored';

$manager = new UglyQueueManager($queueBaseDir);

$tastySandwich = $manager->getQueue('sandwiches');

// 'sandwiches' queue will exist now

$tastySandwich->lock();

// Specify the number of items you wish to retrieve from the queue

$items = $tastySandwich->retrieveItems(4);

// $items is now an array...

var_export($items);

/*
array (
  4 => 'bread',
  3 => 'lettuce',
  2 => 'cheese',
  1 => 'meat',
)
*/

The queue will then retain a single item, 0 => 'bread' as the 5th item left in the queue., (*9)

At any time you can determine how many items remain in a queue by executing count($queueObj);, (*10)

There are a few limitations currently:, (*11)

  1. This lib is designed for small values without much in the way of formatting or line breaks
  2. It is designed to be atomic, meaning that only one process can be adding / retrieving items from a queue at a time. Reading actions (count, searching, etc) are NOT atomic, however.

The Versions

13/10 2015

dev-master

9999999-dev https://github.com/dcarbone/ugly-queue

A simple file-based queue system for PHP 5.3.3+

  Sources   Download

GPLv3

The Requires

 

The Development Requires

by Daniel Carbone

php queue file queue ugly queue

30/09 2015

0.4.0

0.4.0.0 https://github.com/dcarbone/ugly-queue

A simple file-based queue system for PHP 5.3.3+

  Sources   Download

GPLv3

The Requires

 

The Development Requires

by Daniel Carbone

php queue file queue ugly queue

30/10 2014

0.3.1

0.3.1.0 https://github.com/dcarbone/ugly-queue

A simple file-based queue system for PHP 5.3.3+

  Sources   Download

GPLv3

The Requires

 

The Development Requires

by Daniel Carbone

php queue file queue ugly queue

01/10 2014

0.3.0

0.3.0.0 https://github.com/dcarbone/ugly-queue

A simple file-based queue system for PHP 5.3.3+

  Sources   Download

GPLv3

The Requires

 

The Development Requires

by Daniel Carbone

php queue file queue ugly queue

11/08 2014

0.2.2

0.2.2.0 https://github.com/dcarbone/ugly-queue

A simple file-based queue system for PHP 5.3.3+

  Sources   Download

GPLv3

The Requires

 

The Development Requires

by Daniel Carbone

php queue file queue ugly queue

11/08 2014

0.2.1

0.2.1.0 https://github.com/dcarbone/ugly-queue

A simple file-based queue system for PHP 5.3.3+

  Sources   Download

GPLv3

The Requires

 

The Development Requires

by Daniel Carbone

php queue file queue ugly queue

10/08 2014

0.2.0

0.2.0.0 https://github.com/dcarbone/ugly-queue

A simple file-based queue system for PHP 5.3.3+

  Sources   Download

GPLv3

The Requires

 

The Development Requires

by Daniel Carbone

php queue file queue ugly queue

08/08 2014

0.1.0

0.1.0.0 https://github.com/dcarbone/ugly-queue

A simple file-based queue system for PHP 5.3.3+

  Sources   Download

GPLv3

The Requires

 

The Development Requires

by Daniel Carbone

php queue file queue ugly queue