-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Contracts] Add Cache contract to extend PSR-6 with tag invalidation, callback-based computation and stampede protection #28096
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
b5b7e79
to
9c19606
Compare
Now with a |
Also with |
use Psr\Cache\CacheItemPoolInterface; | ||
|
||
/** | ||
* An interface that extends TawAwareCacheInterface with the methods from PSR-6's CacheItemPoolInterface. |
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.
There's a typo: Taw
=> Tag
, also present in the PR description.
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.
fixed thanks
9c19606
to
19904f9
Compare
* | ||
* When implemented on a PSR-6 pool, invalidation should not apply | ||
* to deferred items. Instead, they should be committed as usual. | ||
* This allows replacing old tagged values by news ones without |
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.
new ones
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.
fixed, thanks
19904f9
to
a6659db
Compare
a6659db
to
0868ff4
Compare
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.
Great.
I had a discussion with @nicolas-grekas.
Approved with changes
/** | ||
* An interface that extends TagAwareCacheInterface with the methods from PSR-6's CacheItemPoolInterface. | ||
*/ | ||
interface ExtendedTagAwareCacheInterface extends TagAwareCacheInterface, CacheItemPoolInterface |
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.
As discussed: Remove this.
/** | ||
* An interface that extends CacheInterface with the methods from PSR-6's CacheItemPoolInterface. | ||
*/ | ||
interface ExtendedCacheInterface extends CacheInterface, CacheItemPoolInterface |
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.
We should remove this.
0868ff4
to
805b719
Compare
Thanks @Nyholm , PR updated. |
Thank you. Im 👍 |
09b706b
to
f7cad20
Compare
(rebased) |
f7cad20
to
74506c4
Compare
Addressed, thanks. |
74506c4
to
fe5d5c9
Compare
… callback-based computation and stampede protection
fe5d5c9
to
ca6478b
Compare
interface CacheInterface | ||
{ | ||
/** | ||
* @param callable(ItemInterface):mixed $callback Should return the computed value for the given key/item |
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.
that's the declaration for the return type of the callable
interface CacheInterface | ||
{ | ||
/** | ||
* @param callable(ItemInterface):mixed $callback Should return the computed value for the given key/item |
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.
that's the declaration for the return type of the callable
Thank you @nicolas-grekas. |
…g invalidation, callback-based computation and stampede protection (nicolas-grekas) This PR was merged into the 4.2-dev branch. Discussion ---------- [Contracts] Add Cache contract to extend PSR-6 with tag invalidation, callback-based computation and stampede protection | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - Let's separate the useful interfaces of the Cache component in Contracts. This does not include `PruneableInterface`, `MarshallerInterface` nor `*AdapterInterface` because they are too specific to the component. But `CacheInterface`, `TawAwareCacheInterface` and `ItemInterface` form a nice consistent set of features on top of PSR-6. Updating the Cache component to use these interfaces will be done in a separate PR so that we can focus on the contract itself here. Commits ------- ca6478b [Contracts] Add Cache contract to extend PSR-6 with tag invalidation, callback-based computation and stampede protection
This PR was merged into the 4.2-dev branch. Discussion ---------- [Cache] leverage Contracts\Cache | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - Implementing #28096 Commits ------- 0a1220f [Cache] leverage Contracts\Cache
Let's separate the useful interfaces of the Cache component in Contracts.
This does not include
PruneableInterface
,MarshallerInterface
nor*AdapterInterface
because they are too specific to the component.But
CacheInterface
,TawAwareCacheInterface
andItemInterface
form a nice consistent set of features on top of PSR-6.Updating the Cache component to use these interfaces will be done in a separate PR so that we can focus on the contract itself here.