Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CPM-101: use symfony cache instead of doctrine cache #13665

Merged
merged 5 commits into from
Jan 15, 2021

Conversation

nmarniesse
Copy link
Collaborator

@nmarniesse nmarniesse commented Jan 6, 2021

Doctrine cache bundle is no longer maintained: doctrine/DoctrineCacheBundle#156

Since symfony 4.3 the best way to configure the cache is using the symfony/cache component. In this PR the doctrine-cache-bundle is removed and replaced by symfony/cache. The config is migrated to this new component.

Which configuration to use?

In our previous configuration we had

doctrine_cache:
    providers:
        pim_apcu:
            apcu: ~
        pim_array:
            array: ~
        pim:
            chain:
                providers: [doctrine_cache.providers.pim_apcu, doctrine_cache.providers.pim_array]

The default configuration in SF5 install is defined here: https://github.com/symfony/recipes/blob/master/doctrine/doctrine-bundle/1.6/config/packages/prod/doctrine.yaml
It seems simpler compared to our previous config with a simple and obscure cache.app:

framework:
    cache:
        pools:
            doctrine.result_cache_pool:
                adapter: cache.app
            doctrine.system_cache_pool:
                adapter: cache.system

So I adapt the symfony cache configuration to have the same behavior than before for results only:

framework:
    cache:
        pools:
            doctrine.result_cache_pool:
                adapters:
                    - cache.adapter.apcu
                    - cache.adapter.array
            doctrine.system_cache_pool:
                adapter: cache.system

The doctrine.system_cache_pool is different and used the default cache.system cache. Here is an explaination of this cache https://symfony.com/doc/current/cache.html#configuring-cache-with-frameworkbundle

Benchmarks in local

Load and force save 1239 products 5 times in the same process without clearing cache. The results are the same. The cost to fetch/save product from/in the cache is really low compared to the rest.

Duration in seconds master this PR
Pass 1 127 124
Pass 2 124 133
Pass 3 125 132
Pass 4 120 118
Pass 5 126 112
Average 124.4 123.8
Median 125 124

@nmarniesse nmarniesse force-pushed the CPM-101_rework_doctrine_cache branch from c9d7cf4 to 6c8b754 Compare January 13, 2021 16:35
@nmarniesse nmarniesse force-pushed the CPM-101_rework_doctrine_cache branch from e11173d to c4ba065 Compare January 15, 2021 08:36
@nmarniesse nmarniesse merged commit 5c0f7fa into master Jan 15, 2021
@nmarniesse nmarniesse deleted the CPM-101_rework_doctrine_cache branch January 15, 2021 11:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants