shonm / resque-bundle
通过 php-resque 为 Resque 提供的 Symfony2 扩展包
dev-master
2013-04-29 16:51 UTC
Requires (Dev)
- colinmollenhour/credis: dev-master
- phpunit/phpunit: 3.7.x
- shonm/php-resque: dev-master
- symfony/symfony: >=2.1,<3.0-dev
Suggests
- ebernhardson/fastcgi: Allows php-resque to execute jobs via php-fpm.
- shonm/php-resque-scheduler: Allows use of the scheduler component
- symfony/process: If you want to take advantage of the worker:restart command
This package is not auto-updated.
Last update: 2024-09-19 13:21:23 UTC
README
创建一个任务
// src/Acme/ResqueBundle/Job/TestJob.php namespace Acme\ResqueBundle\Job; class HelloWorldJob { public function perform () { fwrite(STDOUT, "Hello " . $this->args['hello'] . "!\n"); } }
发布你的任务
$container->get('resque')->add('Acme\ResqueBundle\Job\HelloWorldJob', 'queuename', array('hello' => 'world'));
雇佣一个工作者
app/console resque:worker:start queuename
派对!
最佳实践
- 任务应该小巧简单
- 工作者应该是幂等的且事务性的
- 设计并发 - 使用连接池
开发 & 测试
$ composer install --dev
$ bin/phpunit