mombol/php-file-queue 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

mombol/php-file-queue

Composer 安装命令:

composer require mombol/php-file-queue

包简介

A PHP file queue

README 文档

README

A php file queue support:

  • 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

$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

$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();

统计信息

  • 总下载量: 967
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 7
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 7
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2016-10-21

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固