2

我想在项目中使用新的 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 连接。

谢谢

4

0 回答 0