Skip to content

[Cache] Add argument $prefix to AdapterInterface::clear() #32284

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

Merged
merged 1 commit into from
Jul 8, 2019

Conversation

nicolas-grekas
Copy link
Member

Q A
Branch? 4.4
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets -
License MIT
Doc PR -

This PR allows clearing AdapterInterface implementations by prefix of keys. The goal is to fix an edge case situation in ProxyAdapter: right now, when one calls ->clear() on a proxy adapter that is configured to add a prefix to all the keys passed to the decorated pool, we clear it all; while only the subset that starts with the prefix should be.

Since AdapterInterface is an "internal" interface (ie its purpose is to create compatible implementations - NOT to be type-hinted for), this is not really a user-facing change.

/cc @Nyholm, this came out after we talked about proxified chain pools

$prefix = 0 < \func_num_args() ? (string) func_get_arg(0) : '';

if ($this->pool instanceof AdapterInterface) {
return $this->pool->clear($this->namespace.$prefix);
Copy link
Member Author

Choose a reason for hiding this comment

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

here is the targetted behavior of this new argument

@fabpot
Copy link
Member

fabpot commented Jul 8, 2019

Thank you @nicolas-grekas.

@fabpot fabpot merged commit ad6f6cf into symfony:4.4 Jul 8, 2019
fabpot added a commit that referenced this pull request Jul 8, 2019
…r() (nicolas-grekas)

This PR was merged into the 4.4 branch.

Discussion
----------

[Cache] Add argument $prefix to AdapterInterface::clear()

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

This PR allows clearing `AdapterInterface` implementations by prefix of keys. The goal is to fix an edge case situation in `ProxyAdapter`: right now, when one calls `->clear()` on a proxy adapter that is configured to add a prefix to all the keys passed to the decorated pool, we clear it all; while only the subset that starts with the prefix should be.

Since `AdapterInterface` is an "internal" interface (ie its purpose is to create compatible implementations - *NOT* to be type-hinted for), this is not really a user-facing change.

/cc @Nyholm, this came out after we talked about proxified chain pools

Commits
-------

ad6f6cf [Cache] Add argument $prefix to AdapterInterface::clear()
@nicolas-grekas nicolas-grekas deleted the cache-clear-prefix branch July 19, 2019 11:11
@nicolas-grekas nicolas-grekas modified the milestones: next, 4.4 Oct 27, 2019
This was referenced Nov 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants