Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Cache] add "setCallbackWrapper()" on adapters implementing CacheInterface for more flexibility #28588

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
Sep 26, 2018

Conversation

nicolas-grekas
Copy link
Member

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

Preparing my talk at SymfonyLive London, see you all there :)

This allows wrapping the callback passed to ->get($item, $callback, $beta) in a callable that should at least return $callback($item), but can do something around the call.
The default wrapper is locking the key to provide lock-based stampede protection.
That was already the case before this PR, but in a much dirtier way at the design level.
Fixes a few issues found meanwhile.

* An implementation for CacheInterface that provides stampede protection via probabilistic early expiration.
*
* @see https://en.wikipedia.org/wiki/Cache_stampede
*
Copy link
Member

Choose a reason for hiding this comment

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

I think we should move the comment where you moved the implementation.

Copy link
Member Author

Choose a reason for hiding this comment

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

The comment is on the contracts interface now, that's why I removed it here.

@fabpot
Copy link
Member

fabpot commented Sep 26, 2018

Thank you @nicolas-grekas.

@fabpot fabpot merged commit 8cf3625 into symfony:master Sep 26, 2018
fabpot added a commit that referenced this pull request Sep 26, 2018
…nting CacheInterface for more flexibility (nicolas-grekas)

This PR was merged into the 4.2-dev branch.

Discussion
----------

[Cache] add "setCallbackWrapper()" on adapters implementing CacheInterface for more flexibility

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

Preparing my talk at SymfonyLive London, see you all there :)

This allows wrapping the callback passed to `->get($item, $callback, $beta)` in a callable that should at least return `$callback($item)`, but can do something around the call.
The default wrapper is locking the key to provide lock-based stampede protection.
That was already the case before this PR, but in a much dirtier way at the design level.
Fixes a few issues found meanwhile.

Commits
-------

8cf3625 [Cache] add "setCallbackWrapper()" on adapters implementing CacheInterface for more flexibility
@nicolas-grekas nicolas-grekas deleted the cache-gettrait branch September 26, 2018 07:21
@nicolas-grekas nicolas-grekas modified the milestones: next, 4.2 Nov 1, 2018
This was referenced Nov 3, 2018
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