Symfony3 - 缓存组件 - 池定义

时间:2017-11-13 17:29:46

标签: symfony caching pool symfony-3.3 symfony-cache

我想在项目中使用新的Symfony 3缓存组件。 如果我像这样用手定义我的服务,我可以使用它:

app.cache.adapter.array:
    class: 'Symfony\Component\Cache\Adapter\ArrayAdapter'

app.redis.client:
    class: Predis\Client
    factory:   ['Symfony\Component\Cache\Adapter\RedisAdapter', 'createConnection']
    arguments: ["%redis_dsn%", {timeout: 5}]

app.cache.adapter.redis:
    class: Symfony\Component\Cache\Adapter\RedisAdapter
    abstract: true
    arguments:
        -
        - "api"
        - 0

app.cache.adapter.chain:
    class: 'Symfony\Component\Cache\Adapter\ChainAdapter'
    abstract: true
    arguments:
        - ['@app.cache.adapter.array', "@app.cache.adapter.redis"]
        - 0

cache.api:
    parent: "app.cache.adapter.chain"

但是只要我使用cache.pool标签或框架池配置来获取分析器中的数据,我就有异常

framework:        
    cache:
        pools:
            cache.api:
                adapter: "app.cache.adapter.chain"
                public: true
                default_lifetime: 0
                clearer: ~

这是例外

     (1/1) ContextErrorException

Catchable Fatal Error: Argument 1 passed to Symfony\Component\Cache\Adapter\ChainAdapter::__construct() must be of the type array, string given, called in /var/www/julien/htdocs/sccd/website/var/cache/dev/appDevDebugProjectContainer.php on line 4032 and defined
in ChainAdapter.php (line 37)
at ChainAdapter->__construct('+FJMe7Pj5l', 0)in appDevDebugProjectContainer.php (line 4032)
at appDevDebugProjectContainer->getCache_Api_RecorderInnerService()in appDevDebugProjectContainer.php (line 623)
at appDevDebugProjectContainer->getCache_ApiService()in classes.php (line 3292)
at Container->get('cache.api')in appDevDebugProjectContainer.php (line 2629)

有人可以帮我吗?

我使用Symfony v3.3.11和predis / predis v1.1.1进行redis连接。

由于

0 个答案:

没有答案