wp-cli / cache-command

Manages object and transient caches.
MIT License
15 stars 25 forks source link

Add support for ` wp_cache_flush_runtime` #81

Closed spacedmonkey closed 1 year ago

spacedmonkey commented 1 year ago

Feature Request

In WordPress 6.0 wp_cache_flush_runtime function. This function can be used to clear cache keys stored in php memory to free up that memory. Not all object cache support this. For that reason, wp_cache_supports( 'flush_runtime' ) should be called before using this function / command.

A clear and concise description of what you are actually trying to do, and in what way the current version of WP-CLI is not up to the task.

Describe the solution you'd like

Add a new command, like this.

wp cache flush runtime to would call wp_cache_flush_runtime. This is functionality is not supported, then it should fail fast.

janw-me commented 1 year ago

I have a couple of questions:

@spacedmonkey Does wp_cache_flush_runtime clear the cache for the current request. Or can php store stuff in memory that lives beyond the request? If it's on a request basis this would effectively do nothing.

@wp-cli/maintainers Would wp cache flush runtime make sense for the command? wp cache flush already exits, so adding a flag is easy enough. But is this the way to go?

tillkruss commented 1 year ago

Would wp cache flush runtime make sense for the command?

It does not 🙃

Does wp_cache_flush_runtime clear the cache for the current request. Or can php store stuff in memory that lives beyond the request?

It clears it for the current PHP execution, so within a long running CLI process it could be used to flush the runtime cache of the current process without wiping the cache for everyone else.

janw-me commented 1 year ago

Then I would consider this a wont-fix

It would only work during a different command and calling WP_CLI::launch with the right arguments. At that point would just be easier to call wp_cache_flush_runtime()

@tillkruss @spacedmonkey do you agree? if so we can close this issue.

tillkruss commented 1 year ago

IMO this doesn't need a command, no 👍

danielbachhuber commented 1 year ago

@janw-me @tillkruss Thanks for working through this! And thank you @spacedmonkey for the original suggestion 😊

spacedmonkey commented 1 year ago

Created another issue for this https://github.com/wp-cli/wp-cli/issues/5769