socloz/pheanstalk

此软件包已被废弃,不再维护。没有建议的替代软件包。

beanstalkd 队列的 PHP 客户端

dev-master 2012-10-24 16:55 UTC

This package is not auto-updated.

Last update: 2020-01-18 05:33:17 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 许可证下发布