-
Notifications
You must be signed in to change notification settings - Fork 824
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 is not correctly shared between CLI and non-CLI #11145
Comments
Turns out even enabling
I've seen anecdotal reports that redis resolves this, so maybe we should highlight that a bit, too. |
apc.enable_cli
!== true
Chatting with @GuySartorelli on Slack: I've done quite a bit of work on caching with https://github.com/pstaender/silverstripe-redis-cache and there's some good example config for forcing everything over into Redis if one was so inclined. One thing the module cannot do is force |
In my experience,
That blacklist.txt file contains the path to the Silverstripe installation, so that in practice OPCache is not used at all in CLI, it is just configured to be enabled. |
Need to figure out how to get the in-memory cache configured before we have the manifests, since we need it to cache the config (and therefore can't put it in config) See #11257 |
There's still an unmerged pr here |
#11300 makes me super happy, nice work team! 🎉 |
Module version(s) affected
Probably all of 'em, but I've only checked CMS 5 so far
Description
Cache run in the CLI with the PHP ini value
apc.enable_cli
NOT set to true will result in different cache being used compared with non-CLI or CLI withapc.enable_cli
set to true.This can result in cache being out of sync when values are changed in one context but not in the other.
There are two causes:
PhpFilesAdapter
, but the non-CLI context falls back toFilesystemAdapter
explicitly - so they're not even sharing filesystem-level cache.UPDATE
It turns out APCu cache just can't be warmed or cleared from the CLI.
You can make
curl
or similar requests to the server form CLI to warm or clear the webserver APCu cache but that is kinda hacky and has some obvious drawbacks.As I've noted in a comment below I've heard some people saying redis doesn't have this problem - it might make sense to provide support for redis in core with APCu as a fallback. At the very least we should clearly document this known and common problem with the current setup.
How to reproduce
/dev/config
in the browser, and compare withsake dev/config
in the CLI. You should see the old value in the browser, and the new value in the CLI.Possible Solution
The second cause can be fixed right away by just using
PhpFilesAdapter
as the fallback in both contexts if it's supported, but the main problem needs to be fixed by Symfony. See symfony/symfony#53962Additional Context
This is not talking about when running CLI with a different user or PHP version than the web server, which is a known and intentional distinction.
Validations
silverstripe/installer
(with any code examples you've provided)OLD PRs
Notes
Acceptance criteria
PhpFilesAdapter
if available, orFilesystemAdapter
otherwiseApcuAdapter
when mentioning the ability to opt-inKitchen sink CI run: https://github.com/creative-commoners/recipe-kitchen-sink/actions/runs/9898902083
CI PRs
Main PRs
The text was updated successfully, but these errors were encountered: