werkint / cache-bundle
dev-master / 0.1.x-dev
2015-07-17 16:12 UTC
Requires
- php: >=5.6
- doctrine/common: *
- symfony/framework-bundle: *
This package is not auto-updated.
Last update: 2022-02-01 12:49:27 UTC
README
通过标签提供服务缓存的Bundle
此Bundle允许分离命名空间中的服务。您给使用Memcached的服务打上标签,当容器正在编译时,每个服务都会获得一个对应命名空间的doctrine缓存提供程序实例。此外,此Bundle还有助于在命名空间中存储会话。
请注意,服务的完整命名空间可能类似于"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 }