skip to Main Content

Currently I have this on
framework.cache:

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

doctrine.orm:

metadata_cache_driver: redis
result_cache_driver: redis
query_cache_driver: redis

Sure, it doesn’t work, but I have no idea what to even try now. Doing type: pool, pool: cache.app works perfect on Symfony 5/6, but it doesn’t do anything on Symfony 3.4, anyone have any ideas?

2

Answers


  1. Chosen as BEST ANSWER

    Sooo 5 mins after posting I have the answer, everything was in prod/doctrine.yaml...

    doctrine.orm:

    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
    

    framework.cache:

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

    services:

    doctrine.result_cache_provider:
        class: SymfonyComponentCacheDoctrineProvider
        arguments:
            - '@doctrine.result_cache_pool'
    doctrine.system_cache_provider:
        class: SymfonyComponentCacheDoctrineProvider
        arguments:
            - '@doctrine.system_cache_pool'
    

    Bonus edit. How to provide custom namespace:

    Create a pool service services:doctrine.cache_pool:

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

    Then use it in a definition for doctrine.system_cache_provider '@doctrine.system_cache_pool' => '@doctrine.cache_pool'.


  2. This works for me and maybe will be helpful for you too:

    config/packages/cache.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
    

    config/packages/prod/doctrine.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
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search