-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[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
Conversation
…rface for more flexibility
ddaf70c
to
8cf3625
Compare
* An implementation for CacheInterface that provides stampede protection via probabilistic early expiration. | ||
* | ||
* @see https://en.wikipedia.org/wiki/Cache_stampede | ||
* |
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 think we should move the comment where you moved the implementation.
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 comment is on the contracts interface now, that's why I removed it here.
Thank you @nicolas-grekas. |
…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
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.