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] Allow clearing private cache pools in cache:pool:clear#20810

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

@chalasr
Copy link
Member

@chalasrchalasr commentedDec 7, 2016
edited
Loading

QA
Branch?master
Bug fix?no
New feature?yes
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed ticketsn/a
LicenseMIT
Doc PRn/a

Ina2a567d cache pools have been passed topublic: false by default.
The problem is that in 3.2 thecache:pool:clear command has been introduced and usesContainer::get($pool); for clearing them, but the service can't be found since it is private.

So I propose to add a global clearer being able to clear any pool.

nervo reacted with heart emoji
@Koc
Copy link
Contributor

Koc commentedDec 7, 2016

❤️ command as service

chalasr reacted with laugh emoji

@nicolas-grekas
Copy link
Member

Changing the default behavior is a BC break so not possible. Solution 1. is simplest, yet it would make sense to allow clearing any pool with the command I agree. I'd prefer a 3rd option: use the cache pool clearer service to clear by name (method to be added on it to allow so.)
Not a bug though, but a new feature.

@chalasr
Copy link
MemberAuthor

@nicolas-grekas I would like to go for your 3rd option but I believe adding this new method will be difficult since thePsr6CacheClearer doesn't reference pools by id (seePsr6CacheClearer::addPool()). Any clue? Otherwise, solution 2 looks the only working solution for this feature.

Btw, could you please re-label this as a feature? Thanks

@nicolas-grekasnicolas-grekas added Feature and removed Bug labelsDec 7, 2016
@nicolas-grekasnicolas-grekas added this to the3.x milestoneDec 7, 2016
@nicolas-grekas
Copy link
Member

Relabeling done.
Not sure about command as a service.
Since each pool can have a different cache clearer, I think we should not reuse the existing cache.default_clearer for that purpose but create a new service (another Psr6CacheClearer enhanced to fit the need?) dedicated to this use case.

@chalasr
Copy link
MemberAuthor

Thanks for the hints, let's see what it gives.

Status: needs work

@chalasrchalasrforce-pushed theframework/cache-pools-default-public branch fromf7db3cc to435f5e9CompareDecember 7, 2016 19:17
@chalasrchalasr changed the title[Framework] Cache pools must be public for using cache:pool:clear[HttpKernel] Allow clearing private cache pools in cache:pool:clearerDec 7, 2016
@chalasrchalasr changed the title[HttpKernel] Allow clearing private cache pools in cache:pool:clearer[FrameworkBundle][HttpKernel] Allow clearing private cache pools in cache:pool:clearerDec 7, 2016
@chalasrchalasr changed the base branch from3.1 tomasterDecember 7, 2016 19:19
@chalasrchalasrforce-pushed theframework/cache-pools-default-public branch 9 times, most recently fromf2f4465 to54ee65bCompareDecember 7, 2016 21:04
@chalasr
Copy link
MemberAuthor

chalasr commentedDec 7, 2016
edited
Loading

I addeda CachePoolClearer which is quite similar to thePsr6CacheClearer but aCachePoolRegistry referencing pools by id, marked as final and internal. Not sure it is the best way to do it, but it make us able to clear any private cache pool from its id whithout changing the current behavior for cache clearers.

Status: needs review

@chalasrchalasr changed the title[FrameworkBundle][HttpKernel] Allow clearing private cache pools in cache:pool:clearer[FrameworkBundle][HttpKernel] Allow clearing private cache pools in cache:pool:clearDec 7, 2016
@chalasrchalasrforce-pushed theframework/cache-pools-default-public branch from54ee65b toe7bd1c3CompareDecember 7, 2016 22:09
@chalasrchalasrforce-pushed theframework/cache-pools-default-public branch 2 times, most recently from12d7fda tod38ca9dCompareDecember 9, 2016 14:02
@chalasr
Copy link
MemberAuthor

chalasr commentedDec 9, 2016
edited
Loading

@nicolas-grekas changes done, I think we are almost good here

@chalasrchalasr closed thisDec 9, 2016
@chalasrchalasr reopened thisDec 9, 2016
$this->pools[] =$pool;
@trigger_error(sprintf('The %s() method is deprecated since version 3.3 and will be removed in 4.0. Pass an array of pools indexed by name to the constructor instead.',__METHOD__),E_USER_DEPRECATED);

if (!in_array($pool,$this->pools,true)) {

Choose a reason for hiding this comment

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

this block is unrelated to the feature of the PR, should be removed

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

It's about keeping BC. If someone rely onaddPool(), the pool should still be cleared when callingclear(), right? The use ofin_array is to avoid registering the same pool twice in this case. Maybe you've a better one?

Choose a reason for hiding this comment

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

I wouldn't care much: either people use the new way, or the deprecated one. We don't have to handle people doing both IMO.

chalasr reacted with thumbs up emoji
thrownew \InvalidArgumentException(sprintf('Cache pool not found: %s.',$name));
}

$this->pools[$name]->clear();

Choose a reason for hiding this comment

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

fir the shake of completeness:return $this->pools[$name]->clear();

if ($poolinstanceof CacheItemPoolInterface) {
$pool->clear();
}else {
$globalClearer->clearPool($id);

Choose a reason for hiding this comment

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

Now I understand why you needed hasPool :)
This can throw in the middle of a clean because of a missing pool.
Then I propose to replace clearPool($pool) byPsrCacheClearer::getPools() and handle validation with the resulting array.
WDYT?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Either we keephasPool()/clearPool() or we get all the pools and let the caller doing the filtering logic as you propose, it's debatable but I would prefer keep the clearer being a clearer rather than an accessor. As you prefer :)

Choose a reason for hiding this comment

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

let's go for hasPool :)

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

done!

@chalasrchalasrforce-pushed theframework/cache-pools-default-public branch fromd38ca9d to7522dcfCompareDecember 9, 2016 16:04
@nicolas-grekas
Copy link
Member

👍
Status: reviewed

@chalasrchalasrforce-pushed theframework/cache-pools-default-public branch 3 times, most recently fromdaac4e8 to6b94068CompareDecember 10, 2016 10:51
@chalasrchalasrforce-pushed theframework/cache-pools-default-public branch from6b94068 tob71df3fCompareDecember 10, 2016 10:52
@ogizanagi
Copy link
Contributor

ogizanagi commentedDec 10, 2016
edited
Loading

Eithercache.default_clearer orcache.global_clearer needs to be akernel.cache_clearer, but not both, right?

@nicolas-grekas
Copy link
Member

@ogizanagi
Copy link
Contributor

Indeed. Forgot about the fact tags are not inherited anyway when using a parent definition. 👍

@ogizanagi
Copy link
Contributor

However, I found it confusing to reuse the same class for the global cache clearing, even if it's not wired as a kernel cache clearer. What were the arguments against a dedicatedCachePoolRegistry?

@chalasr
Copy link
MemberAuthor

There's no need for accessing pools but only clearing them and like this we can keep pools really private (not accessible from a public service).

@ogizanagi
Copy link
Contributor

Ok. Let's move forward.

👍

@fabpot
Copy link
Member

Thank you@chalasr.

@fabpotfabpot merged commitb71df3f intosymfony:masterDec 10, 2016
fabpot added a commit that referenced this pull requestDec 10, 2016
…n cache:pool:clear (chalasr)This PR was merged into the 3.3-dev branch.Discussion----------[FrameworkBundle] Allow clearing private cache pools in cache:pool:clear| Q             | A| ------------- | ---| Branch?       | master| Bug fix?      | no| New feature?  | yes| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets | n/a| License       | MIT| Doc PR        | n/aIna2a567d cache pools have been passed to `public: false` by default.The problem is that in 3.2 the `cache:pool:clear` command has been introduced and uses `Container::get($pool);` for clearing them, but the service can't be found since it is private.So I propose to add a global clearer being able to clear any pool.Commits-------b71df3f [FrameworkBundle] Allow clearing private cache pools
@chalasrchalasr deleted the framework/cache-pools-default-public branchDecember 10, 2016 14:19
nicolas-grekas added a commit that referenced this pull requestDec 13, 2016
…asr)This PR was merged into the 3.3-dev branch.Discussion----------[HttpKernel] Fix missing psr/cache dev requirement| Q             | A| ------------- | ---| Branch?       | master| Bug fix?      | yes, tests are broken| New feature?  | no| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets | n/a| License       | MIT| Doc PR        | n/aBecause#20810 added a test for the `Psr6CacheClearer` that mocks methods of the `CacheItemPoolInterface`. It should fix the travis build on master and deps=lowCommits-------bd59d75 [HttpKernel] Require psr/cache in dev
@dunglas
Copy link
Member

dunglas commentedDec 14, 2016
edited
Loading

Maybe that this PR breaks tests on master (https://travis-ci.org/symfony/symfony/jobs/183706820) but I don't get exactly what happens (I cannot reproduce in local).

@chalasr
Copy link
MemberAuthor

@dunglas tests are broken on 3.2 as well but this is on master only, so it is not the responsible. I tend to think that your first attempt#20906 was the good, but that tests will stay broken because we released it (maybe I'm wrong, I can't explain it myself).

@fabpotfabpot mentioned this pull requestMay 1, 2017
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@nicolas-grekasnicolas-grekasnicolas-grekas left review comments

Assignees

No one assigned

Projects

None yet

Milestone

3.3

Development

Successfully merging this pull request may close these issues.

7 participants

@chalasr@Koc@nicolas-grekas@ogizanagi@fabpot@dunglas@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp