-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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
[5.8] Refactor caching TTL to seconds #27276
[5.8] Refactor caching TTL to seconds #27276
Conversation
These changes will allow developers more finer granular caching. By allowing caching in seconds, developers can set even more specific caching times. This also makes the caching TTL conform with PSR-16 which states that: > Implementing Libraries MUST support at minimum TTL functionality as described below with whole-second granularity. https://www.php-fig.org/psr/psr-16/ This refactor also simplifies things by removing support for floats and only supporting integers since floats aren't necessary anymore. If you take a look at the refactored tests and internals you'll see that we now do much less calculations. This will have quite an impact on any app implementing caching and should be indicated in the upgrade guide as a high impact change.
I should indeed note that this is already possible by division (1/4) because of the floats but the refactor makes it more obvious and intuitive. And more conform to the PSR. |
Hi, I'm going through the https://laravel.com/docs/5.8/upgrade#upgrade-5.8.0 process (first time ever) and found #27217 and #27276 were referenced in the cache section of upgrade notes. The #27217 changed file In the future should I disregard older posts such as #27217 and only utilize #27276, in this case? (Still trying to figure out all these tools and processes. Thank you`) |
#27217 didn't change it to minutes. It was already minutes. |
Hi @devcircus , yes, I saw that thank you. I may be misinterpreting how to use the upgrade guide but it references both. Reading from top to bottom the newest #27276 is referenced first, so when I came to #27217 I decided to clarify here. Are we supposed to make the changes for |
Not sure I follow. The upgrade guide is just pointing out that ttl has changed from minutes to seconds and that now, psr16 is more closely followed. The two ideas do not oppose each other. If you're digging in to a PR to see exactly how a specific piece of code works, always follow the most recent. Code is always changing. |
So, e.g. on #27276, I completed all the changes first but when I went down the page and started making the next changes the older #27217 conflicted. I may be doing changes in a bad way. idk To be sure...we should be updating the changes in Or does updating the e.g. this line "In the very unlikely event you are implementing this interface, you should add these methods to your implementation." I took that as we manually update our app - just a bit unclear on where the composer.json leaves off and manual updating starts. |
What are you changing using the pull requests? The actual code? |
ha, man, this sounds badd...
e.g. in the above I removed I wish the upgrade guide had a blue boxed tip about this. edit: alright so I just ran so e.g., what is meant, in the docs, by this: I think that's where I got confused. Really appreciate your clarification, as I mentioned this is the first time i've done an upgrade. happy saturday ~ |
Hello. Is method (Illuminate\Cookie\CookieJar)->make() should receive seconds instead minutes (or ttl)? |
No, the code looks correct with minutes? |
@tegos the cookie component was left untouched and still uses minutes. |
Yeah, it looks correct. |
@tegos cookies don't have anything to do with PSR-16. But yeah I suppose it could profit from the same thing. You're free to send in a PR to the master branch for this. |
@driesvints ok, sorry. I sent pr to the master. |
These changes will allow developers more finer granular caching. By allowing caching in seconds, developers can set even more specific caching times.
This also makes the caching TTL conform with PSR-16 which states that:
https://www.php-fig.org/psr/psr-16/
This refactor also simplifies things by removing support for floats and only supporting integers since floats aren't necessary anymore. If you take a look at the refactored tests and internals you'll see that we now do much less calculations.
I've added a separate commit which shows the places in the other components where the new behavior is updated. The changes don't affect other components but we may also consider if other components like auth and especially session could benefit from this.
This will have quite an impact on any app implementing caching and should be indicated in the upgrade guide as a high impact change.