Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[FrameworkBundle] Add CachePoolClearerPass for weak cache pool refs in cache clearers#19900

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

@nicolas-grekas
Copy link
Member

QA
Branch?master
New feature?yes
Tests pass?yes
LicenseMIT

On 3.1, when a cache pool is private and not injected anywhere, it is still added to its clearer service.
TheCachePoolClearerPass fixes this by referencing pools in clearers only after the removing passes.

}
if (isset($attr['clearer'])) {
$clearer = $container->getDefinition($attr['clearer']);
$clearer->addMethodCall('addPool', array(new Reference($id)));
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd rather replace constructor argument with new one.

Copy link
MemberAuthor

@nicolas-grekasnicolas-grekasSep 10, 2016
edited
Loading

Choose a reason for hiding this comment

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

This is how it is now, there is no constructor. I was about to add it, but wouldn't that enforce an unnecessary stronger binding between the actual current implementation and the way things works? Here, the only thing the code needs to know is that anaddPool method can be called. Looks a looser binding than a constructor argument to me. Given that this is not critical perf code to say the least, I think it should be kept asis.

Copy link
Contributor

Choose a reason for hiding this comment

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

The compiler pass is already implementation-aware, becauseaddPool is not part of any interface as I can see. It's more likePsr6CacheClearerPass to be honest.

And I think it's OK for compiler pass to be locked on specific implementation, DIC is the place for this knowledge.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

So, what's your argument supporting the change? (you have mine :) )

Copy link
Contributor

Choose a reason for hiding this comment

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

Given you bother withisset vsarray_key_exists performance, I wonder why you didn't take into account this one. Same kind of micro-optimization for me. :)

And yet another mutable service looks painful, just for sake of clean code.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Given you bother with isset vs array_key_exists performance

I don't know how to react to this. Is it ironic? Or are you wondering why here performance is not and issue, and why it is in the container methods? I'll take the second option. A clearer is called every once in a while. On the container,get can be called thousands of times. 1000xsmall-optim == big optim. That's why it matters there.

Copy link
Contributor

@unkindunkindSep 10, 2016
edited
Loading

Choose a reason for hiding this comment

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

I just wanted to say that I see no reason to prefer setter injection over constructor one. Same level of coupling for me, better performance of constructor injection, cleaner API, less side-effects, etc.

I see that the class has no constructor, but it's not an issue to add it.

Even if somebody added his own implementation, he'd look into this source code and find out that he needs to addaddPool method or adapt constructor signature, i.e. same kind of changes. How setter is looser coupling?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Even if somebody added his own implementation, he'd look into this source code and find out that he needs to add addPool

That's my point yes, and I find that having a convention that applies to a method is more open that one that applies to the constructor. That's why I said looser coupling.

Anyway, this is not directly related to this PR, which is just moving this line of code around, nothing new here.

If you really care, I propose you open a PR to change that.

/**
* @author Nicolas Grekas <p@tchwork.com>
*/
class CachePoolClearerPass implements CompilerPassInterface
Copy link
Contributor

Choose a reason for hiding this comment

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

Why this class is open for inheritance (not marked asfinal)?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

here we are

$clearer = $container->getDefinition($attr['clearer']);
$clearer->addMethodCall('addPool', array(new Reference($id)));
}
if (array_key_exists('clearer', $attr)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand logic behind this code (array_reverse +break). Do you want to emulate overriding of the tag? Does it mean that a service cannot have 2 different clearers?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

cannot have 2 different clearers

True: neither in 3.1 nor with this PR. Could be worth it, I'll give it a try.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

But not in this PR, that's another topic :)

@fabpot
Copy link
Member

Thank you@nicolas-grekas.

@fabpotfabpot merged commitc4b9f7d intosymfony:masterSep 14, 2016
fabpot added a commit that referenced this pull requestSep 14, 2016
…che pool refs in cache clearers (nicolas-grekas)This PR was merged into the 3.2-dev branch.Discussion----------[FrameworkBundle] Add CachePoolClearerPass for weak cache pool refs in cache clearers| Q             | A| ------------- | ---| Branch?       | master| New feature?  | yes| Tests pass?   | yes| License       | MITOn 3.1, when a cache pool is private and not injected anywhere, it is still added to its clearer service.The `CachePoolClearerPass` fixes this by referencing pools in clearers only after the removing passes.Commits-------c4b9f7d [FrameworkBundle] Add CachePoolClearerPass for weak cache pool refs in cache clearers
@nicolas-grekasnicolas-grekas deleted the cache-pool-clearer-pass branchSeptember 14, 2016 19:25
@fabpotfabpot mentioned this pull requestOct 27, 2016
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

5 participants

@nicolas-grekas@fabpot@stloyd@unkind@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp