werkint/redis-bundle

此包已被弃用且不再维护。没有建议的替代包。

通过标签为服务提供命名空间化的Redis的包

安装: 136

依赖者: 0

建议者: 0

安全: 0

星标: 1

关注者: 2

分支: 0

开放问题: 0

类型:symfony-bundle

v0.0.1 2014-08-23 11:27 UTC

This package is not auto-updated.

Last update: 2022-02-01 12:25:53 UTC


README

通过标签为服务提供命名空间化的Redis的包

此扩展允许通过命名空间来分离服务。您为使用Memcached的每个服务添加标签,因此当容器正在编译时,每个服务都会获得一个具有相应命名空间的doctrine缓存提供程序实例。此外,此扩展还有助于在命名空间中存储会话。

请注意,服务的完整命名空间可能是类似于"company_dev_theservice_"的形式,因此您可以在同一台机器上同时运行多个项目实例。

配置

framework:
    ...
    session:
        handler_id: werkint.redis.session
werkint_redis:
    host:   localhost
    port:   11211
    prefix: company_%kernel.environment%
    session:
        prefix: company_%kernel.environment%_sess
        expire: 3600
        provider: redis ; or apc

添加标记的服务(命名空间:"theservice")

services:
    company.service:
        class: Company\MainBundle\Service\Fooservice
        arguments:
            ...
            - @werkint.redis.ns.theservice
        tags:
            - { name: werkint.redis.cache, scope: project, ns: foo  }
<?php
namespace Company\MainBundle\Service;

use Doctrine\Common\Cache\CacheProvider;

class Service
{
    protected $cacher;

    public function __construct(
        CacheProvider $cacher
    ) {
        $this->cacher = $cacher;
    }

    // You now can use doctrine cache provider as usual

}