2017 © Pedro Peláez
 

library php-file-queue

A PHP file queue

image

mombol/php-file-queue

A PHP file queue

  • Monday, October 24, 2016
  • by mombol
  • Repository
  • 1 Watchers
  • 1 Stars
  • 71 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 5 Versions
  • 1 % Grown

The README.md

PHP file queue

A php file queue support:, (*1)

  • multi queue task shared one queue data by queueNamespace.
  • consume queue data by set consumeSpan(in order to avoid the queue data file too large).
  • track the queue cursor position to recover last cursor position(have to call track method manual).

Usage:

Instance

**NOTE**
* All construct parameters are optional for your custom settings.
* set config `role` to `customer` or orthers when process as a customer to consume queue data which shared by multi queue.

File queue instance, (*2)

$FileQueue = new FileQueue(array(
    'silent' => false, // if it is set and is equal to true, just return only one object handler without mount any files
    'role' => 'generator', // queue role, default generator, it must be setted not generator when process as a customer
    'queueNamespace' => 'nsp', // queue namespace to support one queue data shared by multi queue
    'queueDir' => '/var/run/php-file-queue',
    'queueFileName' => 'default',
    'queueFileSuffix' => 'mq',
    'cursorFileSuffix' => 'cursor',
    'initialReadLineNumber' => 0 //  the number of initial read line number, default value set 0 mean that will read from the queue header, the orthers you can set to 'end' which make it read from the queue tail
));

File queue data consumption instance, (*3)

$QueueDataConsume = new QueueDataConsume(array(
    'consumeSpan' => 5, // queue consumption span
    'doConsumeBackup' => true, // whether or not to backup the queue consumption data
    'queueDir' => '/var/run/php-file-queue',
    'queueFileName' => 'default'
));

Push data to queue

$data = 'test'; // anything you want to push
$GerneratorFileQueue->push($data);

Pop data from queue

$num = 1;
$currentPostion = array();
$data = $CustomerFileQueue->pop($num, $currentPostion); // $num : pop number, $currentPostion : current postion after pop a data
// print_r($currentPostion);

Get current position

$pos = $FileQueue->position();

Rewind position to queue header

$FileQueue->rewind();

Point queue cursor to the end

$FileQueue->end();

Track queue cursor and recover last cursor

$FileQueue->track();
$FileQueue->rewind();
// do anything ...
$FileQueue->recover();

Get queue length

$length = $FileQueue->length();

Tests for the end of file queue

while (!$FileQueue->eof()) {
    // do anything ...
}

Unmount queue files

$FileQueue->unmount();

Consume queue data

$QueueDataConsume->consume();

Clean queue data

$QueueDataConsume->clean();

The Versions

24/10 2016

dev-master

9999999-dev

A PHP file queue

  Sources   Download

The Development Requires

by Avatar mombol

24/10 2016

v1.2.2

1.2.2.0

A PHP file queue

  Sources   Download

The Development Requires

by Avatar mombol

24/10 2016

v1.2.0

1.2.0.0

A PHP file queue

  Sources   Download

The Development Requires

by Avatar mombol

20/10 2016

v1.1.0

1.1.0.0

A PHP file queue

  Sources   Download

The Development Requires

by Avatar mombol

14/06 2016

v1.0.0

1.0.0.0

A PHP file queue

  Sources   Download

The Development Requires

by Avatar mombol