-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Add BC layer to handle old objects already present in cache #45876
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
$this->tokens = $data[1]; | ||
$this->timer = $data[2]; | ||
$this->burstSize = $data[3]; | ||
$this->stringRate = $data[4]; |
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.
actualy let's remove this one, remove wakeup and move its logic here
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.
argh no! that'd break compat with php < 7.4
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.
$this->rate = Rate::fromString($data[4]);
then
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.
Oh yeah missed that the stringRate prop does not exist :)
Thank you @Seldaek. |
When reloading an old RateLimiter instance from cache with the new code I did get an exception because windowEndAt was a string and getHitCount does windowEndAt - intervalInSeconds, and string - int fails.
The reason is the new code assigns the id to windowEndAt via:
I dumped $this and $data in __unserialize just FYI and you get this:
I only tested the code in real conditions for SlidingWindow, but I do believe/hope the same applies for the other two policies.