Try to cleanup cache entries with explicit ttl when apc.ttl is 0 #531
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
If the runtime configuration setting apc.ttl is 0 (default value), the function apc_cache_default_expunge() always uses a real expunge and throws away tho whole cache content, even though this is unnecessary and not the documented behavior.
The documentation for apc.ttl says (see https://www.php.net/manual/en/apcu.configuration.php):
"... This setting has no effect on cache entries that have an explicit TTL specified."
The expected behavior is that entries with explicit TTL should be cleaned up first and only if this is insufficient a real expunge should be performed (independent of how apc.ttl is set).
Because apc_cache_entry_expired() takes care of the global apc.ttl setting, no special case is needed for apc.ttl == 0 in apc_cache_default_expunge(). For this reason the code in apc_cache_default_expunge() can be removed to solve the problem.