xsolve-pl/pheanstalk

beanstalkd 队列的 PHP 客户端

dev-master 2012-10-19 08:43 UTC

This package is not auto-updated.

Last update: 2024-09-22 02:54:20 UTC


README

Pheanstalk 是一个纯 PHP 5.2+ 客户端,用于 beanstalkd 工作队列。自 2008 年末以来,它一直处于积极开发状态,并已在生产中使用。

Paul Annesley 创建,Pheanstalk 经过严格的单元测试,并使用封装、可维护的面向对象设计编写。社区反馈、错误报告和补丁导致了 2010 年稳定的 1.0.0 版本的发布。

支持最新版本的 beanstalkd 1.4。实现了 beanstalkd 1.3 版本协议文档中指定的所有命令和响应。

使用示例

<?php

// register Pheanstalk class loader
require_once('pheanstalk_init.php');

$pheanstalk = new Pheanstalk('127.0.0.1');

// ----------------------------------------
// producer (queues jobs)

$pheanstalk
  ->useTube('testtube')
  ->put("job payload goes here\n");

// ----------------------------------------
// worker (performs jobs)

$job = $pheanstalk
  ->watch('testtube')
  ->ignore('default')
  ->reserve();

echo $job->getData();

$pheanstalk->delete($job);

?>

运行测试

# ensure you have simpletest
$ git submodule init
$ git submodule update


$ ./tests/runtests.php
All Tests
OK
Test cases run: 4/4, Passes: 103, Failures: 0, Exceptions: 0


# extra tests relying on a beanstalkd on 127.0.0.1:11300
$ ./tests/runtests.php --with-server
All Tests
OK
Test cases run: 7/7, Passes: 198, Failures: 0, Exceptions: 0


$ ./tests/runtests.php --help

CLI test runner.

Available options:

  --with-server      Includes tests which connect to a beanstalkd server
  --testfile <path>  Only run the specified test file.
  --help             This documentation.

贡献者

许可证

© Paul Annesley

MIT 许可证 下发布