Skip to content

Fall back to NullCache on CLI calls if configured cache is not available #27608

@MichaIng

Description

@MichaIng

How to use GitHub

  • Please use the 👍 reaction to show that you are interested into the same feature.
  • Please don't comment if you have no relevant information to add. It's just extra noise for everyone subscribed to this issue.
  • Subscribe to receive notifications on status change and new comments.

Is your feature request related to a problem? Please describe.
After #25440, Nextcloud requires the configured memory cache (config.php > memcache.local) to be available as well for CLI calls. By default PHP APCu is disabled for CLI calls, which already did produce a log entry in the past and it was always recommended to enable it (apc.enable_cli=1) to avoid potential issues with some background jobs. It is however not optimal to initiate a caching instance for a CLI command, which usually does not repeatedly read the same resource, so that building the cache slows down the whole call more than the benefit of having involved resources cached. Also this can lead to a significant increase of memory usage, when CLI calls stack, each with an own cache instance. This matter has been further discussed in #25770.

Describe the solution you'd like
In case of CLI falls, if the configured memory cache is not available (apc.enable_cli=0 and alike), fallback to NullCache, as if no cache was configured (memcache.local unset or none).

Describe alternatives you've considered
An alternative would be to use NullCache in the first place on all CLI calls, ignoring the memcache.local value. But it won't have any benefit as long as the backend itself (PHP module or server) has been initialised or is running anyway.

Additional context
For me, the related code block already looks like it does what I suggest, but obviously it does not, as otherwise the loop, worked around with #25770 wouldn't exist. Here is how I understand the code (obviously wrong), and hopefully someone can point me to the thing I misinterpret:

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions