-
-
Notifications
You must be signed in to change notification settings - Fork 862
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
Instruct Doctrine Orm Bridge to use result cache or second level cache #2789
Conversation
st-it
commented
May 13, 2019
•
edited
Loading
edited
Q | A |
---|---|
Bug fix? | no |
New feature? | yes |
BC breaks? | no |
Deprecations? | no |
Tests pass? | yes |
Fixed tickets | api-platform/api-platform#1138 |
License | MIT |
Doc PR | api-platform/docs#827 |
Nice one, shouldn't this option be configurable? |
It must be strictly opt-in only. |
@dunglas When you do not have result cache configured this instruction will be ignored by doctrine. @teohhanhui opt-in can be performed by configuring the result cache. However it might be a nice feature to opt-in for specific resources |
@st-it No, there's a reason why it needs to be explicitly enabled per |
Also, the result cache is configured by default: https://github.com/symfony/recipes/blob/master/doctrine/doctrine-bundle/1.6/config/packages/prod/doctrine.yaml |
@teohhanhui but it's not used until |
I like the idea of using attributes for all As @teohhanhui mentions there is no invalidation mechanism. Creating this functionality in api-platform could be a another nice feature. However Doctrine also provides second level cache. It may just provide all the tools an app developer needs to setup result caching and its invalidation. Although marked experimental, as not all use cases might be stable enough, it might be interesting to add support to api-platform and see if it is stable. Adding operation attributes for |
I think, for such advanced use cases, it's easier for the user to implement their own extensions anyway. If we try to handle it, we'll just be making the users learn another syntax needlessly (and limiting the flexibility in the process). |
Conflicts: tests/Bridge/Symfony/Bundle/DependencyInjection/ApiPlatformExtensionTest.php
@teohhanhui Please see the new update in this PR. I think the syntax is close to Doctrines query methods and provides an easy way in to use the result cache or the second level cache. Will create a docs PR soon. |
I'm not convinced. We don't need to create another layer when it brings no benefit. Like I've mentioned, it could easily be done by registering a custom extension. Also, the attributes are already getting too crowded and confusing. If we're actually doing this, then everything should go under the same attribute key, e.g. |
I'll move the attributes to their own namespace, much cleaner! |
@teohhanhui Just moved the cache attributes to their own namespace |
@@ -0,0 +1,112 @@ | |||
<?php |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This class should be an extension that alters the query probably implementing QueryResult{Collection|Item}ExtensionInterface
.
@teohhanhui and @soyuka: I'm having difficulty writing a custom extension implementing |
Mhh this is definitely an issue we should re-design this to add an extension point to add query changes :/. Reading this again I understand why the code took this direction. Having some kind of query interceptor is not a bad idea and I'd change the code in this Pull-Request by:
|
Does it seem easy to archive to you ? |
? Yeah I can do that with ease but I need time to do so ^^ |
Sorry I meant if it would be easy for a young developer like I am :) |
indeed it's not that hard most is done already here and needs moving. |
Unfortunately I didn't found time to update this PR, and not planning to do so soon. So please feel free to give it a try @vasilvestre |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
@st-it is this dead in the water or do you have an example of getting second level caching working without this PR? I enabled everything and could not figure out what I was doing wrong until I saw this post. Still not sure exactly what to do yet but, looks like api platform doesn't support this out of the box? |
open a new issue if needed thanks |
#DONE #6571 |