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

Extend dbal config and extension for result cache #1721

Merged
merged 4 commits into from
Nov 11, 2023

Conversation

chr-hertel
Copy link
Contributor

@chr-hertel chr-hertel commented Oct 31, 2023

This is super embarrassing, what do I overlook, this can't be the solution for #114, right?

tested it successfully with symfony demo:

# config/packages/cache.yaml
framework:
    cache:
        pools:
            cache.dbal:
                adapter: cache.adapter.filesystem
# config/packages/doctrine.yaml
doctrine:
    dbal:
        url: '%env(resolve:DATABASE_URL)%'
        result_cache: 'cache.dbal'
$conn->executeQuery(
    sql: 'SELECT * FROM symfony_demo_post WHERE id = :id',
    params: ['id' => 1],
    qcp: new QueryCacheProfile(
        lifetime: 3600,
        cacheKey: 'my_cache_key',
    ),
);

Copy link
Contributor

@dmaicher dmaicher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this would be enough indeed 🤔

@ostrolucky
Copy link
Member

Why not making it consistent with ORM? There, it's like this

result_cache_driver:
type: pool
pool: doctrine.result_cache_pool

@chr-hertel
Copy link
Contributor Author

chr-hertel commented Nov 4, 2023

Yes, good point, @ostrolucky, consistency would be great.
Trying to understand the implementation here: https://github.com/doctrine/DoctrineBundle/blob/2.10.x/DependencyInjection/DoctrineExtension.php#L1008-L1024

meaning the difference would be that there is a default ArrayCache registered if type pool is used without identifier?

I guess that feature made more sense before #1352 - or do I miss sth?

Edit: not saying it doesn't make sense to bring in that behavior as well, just only if I miss sth to understand before I do the change

@ostrolucky
Copy link
Member

My comment was mostly aimed at the options, not internal workings. In this PR you accept only service ID, while in ORM version you can choose if you use service id or a pool. But perhaps you are right, since DBAL supports symfony pool only, perhaps we should bite the bullet and just accept that ORM and DBAL node will be different and accept just service id. Any opinions from other maintainers on this?

@dmaicher
Copy link
Contributor

dmaicher commented Nov 7, 2023

I think its fine to just allow a service id.

Actually every cache pool is registered as a service with the pool name as service id anyway, right? So this will allow using cache pools or any custom service (as long as its a PSR cache).

The ORM config technically also still supports the deprecated doctrine/cache instances via CacheCompatibilityPass. But we should not support those for the DBAL result cache.

Copy link
Member

@ostrolucky ostrolucky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough. Let's keep it as this then. Test wouldn't be bad either, but can't really go wrong with such simple change either.

@dmaicher
Copy link
Contributor

This should go into 2.11.x though. Could you rebase it @chr-hertel ?

@ostrolucky ostrolucky changed the base branch from 2.10.x to 2.11.x November 10, 2023 21:32
@ostrolucky
Copy link
Member

Target changed. No need to rebase :)

@chr-hertel
Copy link
Contributor Author

Too late :D

@dmaicher dmaicher added this to the 2.11.0 milestone Nov 11, 2023
Copy link
Contributor

@dmaicher dmaicher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's add a very simple test case so at least the feature is also "documented" via tests

DependencyInjection/Configuration.php Show resolved Hide resolved
@dmaicher dmaicher merged commit d7f67f5 into doctrine:2.11.x Nov 11, 2023
14 checks passed
@dmaicher
Copy link
Contributor

Thanks @chr-hertel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants