WordPress.org

Ready to get started?Download WordPress

Ideas

Transient API should allow delete by prefix

  1. webaware
    Member

    I use the transient API as a simple caching mechanism for heavy queries. Rather than delete each cached item individually when it needs to be invalidated, it would be nice to be able to delete all transients with a specific prefix. e.g.

    delete_transient_prefixed('myprefix');

    What I currently need to do is this, which works (for now) but doesn't take into account additional caching mechanisms like memcached:

    global $wpdb;
    
    $sql = "
        delete from {$wpdb->options}
        where option_name like '_transient_myprefix%' or option_name like '_transient_timeout_myprefix%'
    ";
    return $wpdb->query($sql);
    Posted: 1 year ago #
  2. Maor Chasen
    Member

    +1. Sounds like a good idea!

    Posted: 1 year ago #
  3. I agree. I think it is a good Idea.

    Posted: 1 year ago #
  4. Jonathan Dingman
    Member

    12345

    If you guys like the idea, make you sure vote it with 5 stars.

    Posted: 1 year ago #
  5. Agence Web Maroc
    Member

    12345

    +5 stars. Sounds like a good idea!

    Posted: 1 year ago #
  6. Yakup Hoca
    Member

    12345

    +5 stars. Sounds like a good idea!

    Posted: 1 year ago #

RSS feed for this topic

Reply

You must log in to post.

  • Rating

    12345
    9 Votes
  • Status

    This idea is under consideration