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] Apcu adapter in CLI #36399
Comments
This would add runtime overhead for a piece of code that can be found in critical code paths. |
If we determine can the adapter work in this environment or not in class ApcuTrait
{
/**
* @var bool
*/
private $doNothing;
private function init(string $namespace, int $defaultLifetime, ?string $version)
{
$this->doNothing = 'cli' === \PHP_SAPI && !filter_var(ini_get('apc.enable_cli'), FILTER_VALIDATE_BOOLEAN);
...
}
protected function doFetch(array $ids)
{
if ($this->doNothing) {
return [];
}
...
}
} |
But, isn't this warning a good thing? If Im trying to use the Apcu cache when APC is disabled, I should get a warning. If we mute the warnings then I might believe the cache is working. |
@Nyholm Actually APC is enabled for FPM but disabled for CLI which is a common behavior, not an exceptional case. So if I want to warm up the cache in CLI I expect Redis adapter warms it up but APC just be skipped and will work only for in FPM. |
Yes. I know. I understand that.
From your point of view, I understand that it would make sense not to have a warning. But technically speaking; You are telling both RedisAdapter and ApcuAdapter to warmup. Since ApcuAdapter cannot warm up on your (normal) system, it has to log a warning. Same thing if your Redis server was unavailable you would expect a warning from the RedisAdapter. The workaround is to tell only Redis adapter to warmup or to ignore the warning. |
Description
APCu cache adapter works when
apc.enabled
is on, however, in CLI mode with theapc.enable_cli
turned off, the adapter generates a lot of messages likeFailed to save key
.For the system cache, this was fixed in #23390 by installing
NullLogger
in the adapter.However, the problem persists for example in this configuration:
I suggest checking the
apc.enable_cli
option in each method, and do nothing in CLI mode, don't try to call acpu functions.Something like this:
If this is a good solution, I will create a PR. If not, what decision do you think would be good?
The text was updated successfully, but these errors were encountered: