-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Multi Get support for Second Level Cache #954
Conversation
Hello, thank you for creating this pull request. I have automatically opened an issue http://www.doctrine-project.org/jira/browse/DDC-2982 We use Jira to track the state of pull requests and the versions they got |
I have not added tests yet because i think that it has to be discussed... |
I'd like to suggest That will remove the |
@FabioBatSilva ok, but then have i to edit |
@FabioBatSilva |
@FabioBatSilva i do not understand how to implement |
It depends on CacheProvider because cache regions use For the |
I'm not sure to use inheritance over composition inside |
some proceedings ? |
at the moment i'm very busy... :-( |
@goetas since doctrine/cache#29 is fixed, could you eventually complete this PR next week, so that we can throw it in the final 2.5 release? (probably doing it while at PHPBNL15) |
@Ocramius i can to look at this this evening or on tomorrow....! |
if ($mapping['cache']) { | ||
$targetPersister = $em->getUnitOfWork()->getEntityPersister($mapping['targetEntity']); | ||
|
||
if ($targetPersister instanceof CachedPersister) { |
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.
I really hate this nested if
... but I do not know why $em->getUnitOfWork()->getEntityPersister($mapping['targetEntity']);
somtimes seems to be instance of BasicEntityPersister
.... and not a cache persister as expected...
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.
Ping @guilhermeblanco about this
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.
found that one!
I don not know why but Doctrine\Tests\Models\CMS\CmsUser::$articles
is marked as cacheable (but CmsArticle
is not!)... and this is the only failing test case
@Ocramius rebased and tested (a bit) |
Thanks @goetas. I'm stuck on another PR and the current build failure, but I'll get to this one tonight, hopefully. |
* @since 2.5 | ||
* @author Asmir Mustafic | ||
*/ | ||
interface MultiGetRegion extends Region |
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.
Don't extend from larger interfaces unless strictly needed
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.
Does it make sense? A MultiGetRegion
region is always a region. Of course, the new interface is much simpler, but can it be used alone? I can not imagine a use case.
This PR should introduce a dependency to |
$targetRegion = $targetPersister->getCacheRegion(); | ||
|
||
if ($targetRegion instanceof MultiGetRegion) { | ||
return new MultiGetCollectionHydrator($em); |
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.
The multi-get region is not being passed to the MultiGetCollectionHydrator
? You are doing a lot of checks but discarding a lot of dependencies then: is it intended to be like that?
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.
With the first version I was re-building the multi-get region on each loadCacheEntry
:-( , while now I pass it as a constructor argument.
Your suggestion makes it simpler and faster, thanks! :-)
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.
I have "fixed" this problem with goetas@e5ee538 but i think that is not the right solution...
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.
@Ocramius what about this?
@@ -202,7 +218,11 @@ public function getRegion(array $cache) | |||
|
|||
$cacheAdapter->setNamespace($cache['region']); | |||
|
|||
$region = new DefaultRegion($cache['region'], $cacheAdapter, $this->regionsConfig->getLifetime($cache['region'])); | |||
if ($cacheAdapter instanceof MultiGetCache) { |
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.
$region = ($cacheAdapter instanceof MultiGetCache)
? new DefaultMultiGetRegion($cache['region'], $cacheAdapter, $this->regionsConfig->getLifetime($cache['region']))
: new DefaultRegion($cache['region'], $cacheAdapter, $this->regionsConfig->getLifetime($cache['region']));
@guilhermeblanco I've tried to implement |
@guilhermeblanco solved the [bug](goetas@0b57935#diff-408359faa7db56dc64cf1f0b2006625dL8%5D! :-) Versioned classes can't be cacheable as associations.... /cc @Ocramius |
…eed to segregate the interface here)
…Common\Cache\Cache` instances
…ultMultiGetRegion` instantiation logic
Merged after applying following changes:
The SRP violation of
|
Thanks @goetas! |
Hi!
As discussed here i have implemented some kind of multi-get for second level cache implementation.
I have also created a PR to doctrine/cache component (see doctrine/cache#29) that enables this feature at driver cache level.