如何在Symfony 3.4上使用Redis的Doctrine结果缓存

fcipmucu  于 2022-11-16  发布在  Redis
关注(0)|答案(2)|浏览(123)

目前我在framework.cache上有这个:

app: cache.adapter.redis
default_redis_provider: redis://localhost

条令.表格:

metadata_cache_driver: redis
result_cache_driver: redis
query_cache_driver: redis

当然,它不工作,但我不知道什么,甚至尝试现在。做类型:游泳池,游泳池:wwwcache.app在Symfony 5/6上运行得很好,但在Symfony 3.4上却没有任何作用,有人有什么想法吗?

lnlaulya

lnlaulya1#

这对我很有效,也许对你也有帮助:
配置/包/缓存.yaml

framework:
    cache:
        prefix_seed: '%env(resolve:APP_NAME)%'
        app: cache.adapter.redis
        default_redis_provider: '%env(resolve:REDIS_DSN)%'
        pools:
            doctrine.result_cache_pool:
                adapter: redis_adapter
                provider: redis_provider
            doctrine.system_cache_pool:
                adapter: cache.adapter.apcu

配置/包/产品/条令.yaml

doctrine:
    dbal:
    # ...
    orm:
        auto_generate_proxy_classes: false
        metadata_cache_driver:
            type: pool
            pool: doctrine.system_cache_pool
        query_cache_driver:
            type: pool
            pool: doctrine.system_cache_pool
        result_cache_driver:
            type: pool
            pool: doctrine.result_cache_pool
4c8rllxm

4c8rllxm2#

所以5分钟后张贴我有答案,一切都是在prodd/doctrine. yaml...

条令.表格:

metadata_cache_driver:
    type: service
    id: doctrine.system_cache_provider
query_cache_driver:
    type: service
    id: doctrine.system_cache_provider
result_cache_driver:
    type: service
    id: doctrine.result_cache_provider

框架.缓存:

app: cache.adapter.redis
system: cache.adapter.redis
default_redis_provider: redis://localhost

服务:

doctrine.result_cache_provider:
    class: Symfony\Component\Cache\DoctrineProvider
    arguments:
        - '@doctrine.result_cache_pool'
doctrine.system_cache_provider:
    class: Symfony\Component\Cache\DoctrineProvider
    arguments:
        - '@doctrine.system_cache_pool'

附加编辑.如何提供自定义名称空间:

创建池服务服务:doctrine.cache_pool:

doctrine.cache_pool:
    parent: 'cache.app'
    tags:
        - { name: 'cache.pool', namespace: 'app' }

然后将其用于教义的定义中。

相关问题