h4cc / pheanstalk-bundle-extra
LeezyPheanstalkBundle 的额外类
0.1.1
2014-10-18 10:35 UTC
Requires
- leezy/pheanstalk-bundle: ~2.0
Requires (Dev)
- phpunit/phpunit: ~3.7
This package is not auto-updated.
Last update: 2024-09-10 01:16:43 UTC
README
h4cc/LeezyPheanstalkBundleExtra
一些额外的类,用于与 LeezyPheanstalkBundle 一起使用。
此包目前包含以下内容
- PrefixedTubePheanstalkProxy - 一个 Pheanstalk 代理,用于给所有使用的 tubes 添加前缀。
安装
可以使用以下命令安装此包
php composer.phar require h4cc/pheanstalk-bundle-extra:dev-master
提示:如果可用,请使用更稳定的版本!
PrefixedTubePheanstalkProxy
此代理可以给所有 tubes 添加一个指定的前缀。
新方法包括
PrefixedTubePheanstalkProxy
- setTubePrefix($prefix);
- getTubePrefix();
在 Symfony2 中使用自定义代理
将代理定义为服务
services.xml
<service id="your_app.pheanstalk.proxy" class="h4cc\LeezyPheanstalkBundleExtra\Proxy\PrefixedTubePheanstalkProxy">
<call method="setTubePrefix">
<argument>your_app_</argument>
</call>
</service>
或者
services.yml
services:
your_app.pheanstalk.proxy:
class: "h4cc\LeezyPheanstalkBundleExtra\Proxy\PrefixedTubePheanstalkProxy"
calls:
- [ setTubePrefix, [ "your_app_" ] ]
在 app/config/config.yml 中激活代理,如下所示
leezy_pheanstalk:
enabled: true
pheanstalks:
primary:
server: 127.0.0.1
port: 11300
timeout: 60
default: true
proxy: your_app.pheanstalk.proxy
更干净的方式是将 TubePrefix 字符串定义为参数。