You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feature #27031 [Cache] Use sub-second accuracy for internal expiry calculations (nicolas-grekas)
This PR was merged into the 4.2-dev branch.
Discussion
----------
[Cache] Use sub-second accuracy for internal expiry calculations
| Q | A
| ------------- | ---
| Branch? | master
| Bug fix? | no
| New feature? | not really
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | -
| License | MIT
| Doc PR | -
Embeds #26929, #27009 and #27028, let's focus on the 4th commit for now.
This is my last significant PR in the Cache series :)
By using integer expiries internally, our current implementations are sensitive to abrupt transitions when time() goes to next second: `$s = time(); sleep(1); echo time() - $s;` *can* display 2 from time to time.
This means that we do expire items earlier than required by the expiration settings on items.
This also means that there is no way to have a sub-second expiry. For remote backends, that's fine, but for ArrayAdapter, that's a limitation we can remove.
This PR replaces calls to `time()` by `microtime(true)`, providing more accurate timing measurements internally.
Commits
-------
08554ea [Cache] Use sub-second accuracy for internal expiry calculations
thrownewInvalidArgumentException(sprintf('Expiration date must implement DateTimeInterface or be null, "%s" given', is_object($expiration) ? get_class($expiration) : gettype($expiration)));
97
97
}
@@ -105,11 +105,11 @@ public function expiresAt($expiration)
thrownewInvalidArgumentException(sprintf('Expiration date must be an integer, a DateInterval or null, "%s" given', is_object($time) ? get_class($time) : gettype($time)));
0 commit comments