Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[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

Merged
nicolas-grekas merged 1 commit intosymfony:4.3fromnicolas-grekas:cache-expiry
Oct 4, 2019

Conversation

@nicolas-grekas
Copy link
Member

@nicolas-grekasnicolas-grekas commentedOct 4, 2019
edited
Loading

QA
Branch?4.3
Bug fix?yes
New feature?no
Deprecations?no
TicketsFix#31573,Fix#33837
LicenseMIT
Doc PR-

Because the expiration count-down starts immediately after callingCachItem::expiresAfter(N), it's impossible to actually cache items for more thanN-1 seconds.

This PR adds a 0.1s grace period so that backends that have a second-level resolution can store the items forN seconds, 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 inContractsTrait.

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)) {
Copy link
Member

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).

Copy link
MemberAuthor

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.

nicolas-grekas added a commit that referenced this pull requestOct 4, 2019
…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
@nicolas-grekasnicolas-grekas merged commitba63e18 intosymfony:4.3Oct 4, 2019
@fabpotfabpot mentioned this pull requestOct 7, 2019
@nicolas-grekasnicolas-grekas deleted the cache-expiry branchOctober 8, 2019 11:49
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@javiereguiluzjaviereguiluzjaviereguiluz left review comments

Assignees

No one assigned

Projects

None yet

Milestone

4.3

Development

Successfully merging this pull request may close these issues.

3 participants

@nicolas-grekas@javiereguiluz@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp