Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[Cache] give 100ms before starting the expiration countdown#33846
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
| if (null ===$item->expiry) { | ||
| $ttl =0 <$item->defaultLifetime ?$item->defaultLifetime :0; | ||
| }elseif (0 >=$ttl = (int) ($item->expiry -$now)) { | ||
| }elseif (0 >=$ttl = (int) (0.1 +$item->expiry -$now)) { |
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 could look like a "magic number" in the future and people won't understand why we use it. We could add a very brief comment explaining "why" ... or we could move this to a self-explanatory private constant (e.g.self::MINIMUM_CACHE_TTL or something better).
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 value is spread in many unrelated adapters, a private constant doesn't work.
I'm not sure this deserves more honestly,git blame can tell why if anyone wonders.
…n (nicolas-grekas)This PR was merged into the 4.3 branch.Discussion----------[Cache] give 100ms before starting the expiration countdown| Q | A| ------------- | ---| Branch? | 4.3| Bug fix? | yes| New feature? | no| Deprecations? | no| Tickets |Fix#31573,Fix#33837| License | MIT| Doc PR | -Because the expiration count-down starts immediately after calling `CachItem::expiresAfter(N)`, it's impossible to actually cache items for more than `N-1` seconds.This PR adds a 0.1s grace period so that backends that have a second-level resolution can store the items for `N` seconds, provided the time between calling `CachItem::expiresAfter(N)` and saving the value to the backend is lower than 0.1s.This PR also fixes the calculation of the computation time in `ContractsTrait`.Commits-------ba63e18 [Cache] give 100ms before starting the expiration countdown
Uh oh!
There was an error while loading.Please reload this page.
Because the expiration count-down starts immediately after calling
CachItem::expiresAfter(N), it's impossible to actually cache items for more thanN-1seconds.This PR adds a 0.1s grace period so that backends that have a second-level resolution can store the items for
Nseconds, provided the time between callingCachItem::expiresAfter(N)and saving the value to the backend is lower than 0.1s.This PR also fixes the calculation of the computation time in
ContractsTrait.