-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Cache] Unconditionally use PhpFilesAdapter for system pools #27549
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
[Cache] Unconditionally use PhpFilesAdapter for system pools #27549
Conversation
b2b40e4
to
8cf36c7
Compare
There is one problem with PhpFilesAdapter - it does not use opcache till next request.
|
8cf36c7
to
19c30c9
Compare
After having a deeper look, it does, but only if the file's mtime is in the past. This is now fixed. Thanks for the hint. |
to pass tests it should invalidate cache on file deletion (opcache_invalidate should be called before file is unlinked) |
19c30c9
to
df6dddb
Compare
That would open race conditions (invalidating, then a concurrent request reloads the legacy file, then we write but this is ignored). |
df6dddb
to
647cfcc
Compare
Hum, dunno why but tests pass locally and not the CI. I added the call you suggested but still red. Any idea why? |
calls to $cache->delete() or $cache->clear() unlinks files. but opcache is still has file cached. And |
|
647cfcc
to
22bf5c3
Compare
Thanks, patch applied. |
opcache_invalidate should be called before unlink |
invalidate fails when file does not exits and opcache still contains file entry. |
d1f6da9
to
cc1edab
Compare
Thanks, now green! |
cc1edab
to
ce1a15d
Compare
@@ -43,7 +43,6 @@ public function __construct(string $file, AdapterInterface $fallbackPool) | |||
{ | |||
$this->file = $file; | |||
$this->pool = $fallbackPool; | |||
$this->zendDetectUnicode = ini_get('zend.detect_unicode'); |
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.
No need to deal with zend.detect_unicode
anymore when this line is removed. Let's remove the related complexity and overhead.
ce1a15d
to
c91b778
Compare
@@ -87,9 +87,13 @@ function ($deferred, $namespace, &$expiredIds) use ($getId) { | |||
* @param LoggerInterface|null $logger | |||
* | |||
* @return AdapterInterface | |||
* | |||
* @deprecated since Symfony 4.2. |
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.
no dot at the end (I know, our conventions are hard to follow :)).
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.
updated
c91b778
to
51381e5
Compare
Thank you @nicolas-grekas. |
… pools (nicolas-grekas) This PR was merged into the 4.2-dev branch. Discussion ---------- [Cache] Unconditionally use PhpFilesAdapter for system pools | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | yes | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - Now that we're about to leverage OPCache shared memory even for objects (see #27543), there's no reason anymore to use APCu for system caches. Let's remove some complexity here. As a bonus, this makes system caches pruneable using the `cache:pool:prune` command. Commits ------- 51381e5 [Cache] Unconditionally use PhpFilesAdapter for system pools
*/ | ||
public static function createSystemCache($namespace, $defaultLifetime, $version, $directory, LoggerInterface $logger = null) | ||
{ | ||
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.2.', __CLASS__), E_USER_DEPRECATED); |
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.
shouldn't it be __METHOD__
?
…sAdapter for system pools" (nicolas-grekas) This PR was merged into the 4.2-dev branch. Discussion ---------- Revert "feature #27549 [Cache] Unconditionally use PhpFilesAdapter for system pools" This reverts commit d4f5d46, reversing changes made to 7e3b7b0. | Q | A | ------------- | --- | Branch? | 4.2 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - Reading #28800, I've just realized that #27549 breaks using system caches with read-only filesystem. Using ApcuAdapter makes system caches compatible with read-only filesystems. Note that this affects only non-warmed up pools, as the warmed-up ones use a faster `PhpArrayAdapter` in front. Commits ------- dbc1230 Revert "feature #27549 [Cache] Unconditionally use PhpFilesAdapter for system pools (nicolas-grekas)"
Now that we're about to leverage OPCache shared memory even for objects (see #27543), there's no reason anymore to use APCu for system caches. Let's remove some complexity here.
As a bonus, this makes system caches pruneable using the
cache:pool:prune
command.