在Symfony包中使用缓存
我正在编写一个Symfony包,其中使用了缓存组件 我希望使用捆绑包的应用程序能够覆盖正在使用的缓存提供程序。最好的方法是什么? 到目前为止,我已经做到了。我已定义要使用的默认自定义缓存池:在Symfony包中使用缓存,symfony,caching,Symfony,Caching,我正在编写一个Symfony包,其中使用了缓存组件 我希望使用捆绑包的应用程序能够覆盖正在使用的缓存提供程序。最好的方法是什么? 到目前为止,我已经做到了。我已定义要使用的默认自定义缓存池: services: cache.sfes: parent: 'cache.system' tags: - { name: cache.pool } # Seems the only reason for this is to see the
services:
cache.sfes:
parent: 'cache.system'
tags:
- { name: cache.pool } # Seems the only reason for this is to see the pool in the Symfony toolbar
MyBundle\MyService:
arguments:
- '@cache.sfes'
在使用此捆绑包的应用程序中,我尝试覆盖cache.sfes
以使用其他缓存提供程序,例如:
cache.sfes:
class: Symfony\Component\Cache\Adapter\RedisAdapter
arguments:
- '@snc_redis.cache' # a Predis\Client instance
- '%deploy_env_prefix%es_cache'
这通常是可行的,但是覆盖缓存不会显示在Symfony工具栏中。
但这样做不起作用:
cache.sfes:
class: Symfony\Component\Cache\Adapter\RedisAdapter
arguments:
- '@snc_redis.cache' # a Predis\Client instance
- '%deploy_env_prefix%es_cache'
tags:
- { name: cache.pool }
并给出一个错误:
Argument 2 passed to Symfony\Component\Cache\Adapter\AbstractAdapter::createConnection() must be of the type array, string given, called in /blabla/ContainerUkKHm0d/srcApp_KernelDevDebugContainer.php on line 26206
所以我想这不是正确的方法