Skip to content

Be explicit for no results when using wp transient list and external object cache #61

Closed

Description

@GaryJones

When using an external object cache, transients are stored in the object cache and not in the database.

wp transient get ... will still work correctly, as it wraps the get_transient() or get_site_transient() functions.

However, wp transient list will always return an empty table, as the handler for the WP-CLI command generates some SQL to explicitly look in the options or sitemeta tables, which will be empty of transients.

Could we have an early guard clause for the list() method that reminds users that transients are stored in the object cache and so can't be displayed, if the object cache is being used?

(At least until WP core has get_transients() function that can be wrapped.)

Activity

  1. changed the title [-]Be explicit for not results when using wp transient list and external object cache[/-] on Mar 13, 2020
  2. sjaks commented on Jul 24, 2020

    @sjaks

    The wp transient list command should indeed show a message that object cache is in use, at the very least. The expected behavior is to get the cached transients as stated in Transient_Command.php#L15. It would be important to wrap object cache.

  3. mackensen commented on Aug 9, 2021

    @mackensen

    This was a real head-scratcher when I encountered it today. If you're using Redis (for example) you can do something like KEYS XXX:transient:*, where XXX is the site id, to get all the transients, but that's not cross-platform and there doesn't seem to be a core function for getting object cache keys.

  4. GaryJones commented on Jun 5, 2022

    @GaryJones
    Author

    Adding a guard clause of wp_using_ext_object_cache() at the start of https://github.com/wp-cli/cache-command/blob/main/src/Transient_Command.php#L76 may be sufficient.

  5. danielbachhuber commented on Feb 16, 2023

    @danielbachhuber
    Member

    @GaryJones Want to submit a pull request for what you might suggest?

  6. GaryJones commented on Feb 21, 2023

    @GaryJones
    Author

    @danielbachhuber It's not something I'm going to get around to anytime soon, so please go ahead :-)

  7. added this to the 2.0.11 milestone on Feb 24, 2023
  8. danielbachhuber commented on Feb 24, 2023

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

Metadata

Metadata

Labels

command:cacheRelated to 'cache' command

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions