[Cache] Unconditionally use PhpFilesAdapter for system pools#27549
[Cache] Unconditionally use PhpFilesAdapter for system pools#27549fabpot merged 1 commit intosymfony:masterfrom
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 list($expiresAt, $values[$id]) = include $file; returns data. Tests pass when opcache is not working (opcache_cli = false)
|
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
| { | ||
| $this->file = $file; | ||
| $this->pool = $fallbackPool; | ||
| $this->zendDetectUnicode = ini_get('zend.detect_unicode'); |
There was a problem hiding this comment.
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
| * | ||
| * @return AdapterInterface | ||
| * | ||
| * @deprecated since Symfony 4.2. |
There was a problem hiding this comment.
no dot at the end (I know, our conventions are hard to follow :)).
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) | ||
| 8000 | { | |
| @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.2.', __CLASS__), E_USER_DEPRECATED); |
…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:prunecommand.