Skip to content

Add wp theme cache command #392

Open

Description

@spacedmonkey

Feature Request

Describe your use case and the problem you are facing

Add the following commands

wp theme cache <theme> get <key> 
wp theme cache <theme> add <key> <data>
wp theme cache <theme> delete

Describe the solution you'd like

Add command would map to the method cache_add on WP_Theme class.
Get command would map to the method cache_get on WP_Theme class.
Delete command would map to the method cache_delete on WP_Theme class.

This would help manage and clear theme related caches.

Activity

  1. spacedmonkey commented on Jan 16, 2024

    @spacedmonkey
    Author

    This would be useful for cache invalidation of theme caches, related to current performance work.

    CC @swissspidy @joemcgill @felixarntz

  2. danielbachhuber commented on Jan 16, 2024

    @danielbachhuber
    Member

    I amenable to this. Feel free to submit a pull request, if you'd like. Here is some guidance on our pull request best practices.

  3. swissspidy commented on Jan 16, 2024

    @swissspidy
    Member

    WP_Theme::cache_add() and WP_Theme::cache_get() are private, so we can't really use these.

    The delete method is public, but maybe this could be used via wp cache delete and wp cache flush-group? The cache key property itself is also private though, so we can't really access it.

  4. spacedmonkey commented on Jan 17, 2024

    @spacedmonkey
    Author

    WP_Theme::cache_add() and WP_Theme::cache_get() are private, so we can't really use these.

    It maybe possible to use a reflection or copy the logic from inside these methods.

    The delete method is public, but maybe this could be used via wp cache delete and wp cache flush-group? The cache key property itself is also private though, so we can't really access it.

    It is not possible, as the cache key is not predictable. See. Cache key have been salted with a cache hash. Not be mention the other cache clearing that happens in the cache_delete method.

  5. mchirag2002 commented on May 31, 2024

    @mchirag2002

    Can we maybe try to replicate the exact functions being internally used in class-wp-theme.php for these functions? We can replicate the entire logic for the functions and along with it replicate the cache related dependencies for the CLI Command like cache_expiration and cache_hash as well.

  6. spacedmonkey commented on Jun 1, 2024

    @spacedmonkey
    Author

    Can we maybe try to replicate the exact functions being internally used in class-wp-theme.php for these functions? We can replicate the entire logic for the functions and along with it replicate the cache related dependencies for the CLI Command like cache_expiration and cache_hash as well.

    What would the be the benefit of that?

  7. mchirag2002 commented on Jun 3, 2024

    @mchirag2002

    What would the be the benefit of that?

    The benefit would be that we shall be able to replicate the complete functionality of the private functions WP_Theme::cache_add() and WP_Theme::cache_get() directly for our CLI commands without creating any wrapper functions in the class-wp-theme.php

  8. swissspidy commented on Feb 17, 2026

    @swissspidy
    Member

    While I had a WIP PR in #494, I am still not sure about this. Don't really see the use case for the proposed cache add and cache get commands. What would one do with these? 🤷 wp theme cache flush <theme> and wp theme cache delete <theme> are more interesting for cleanup purposes.

  9. swissspidy commented on Aug 10, 2026

    @swissspidy
    Member
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions