• Resolved gstan07

    (@gstan07)


    I use wp fragment cache on my website this way:

    if ( ! WP_Fragment_Cache::output( “photo_gallery_page”, 600 ) ){

    //cache galllery page

    WP_Fragment_Cache::store();
    }

    If i want to delete that cache entry before it expires, what method should i call?
    I was thinking on something like:
    WP_Fragment_Cache::purge( “photo_gallery_page”)
    but id does not seem to work.

    What am i doing wrong?

    Thanks

    https://ww.wp.xz.cn/plugins/wp-fragment-cache/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author mariuspass

    (@mariuspass)

    You can’t delete just one fragment, the purge function deletes all the fragments, also that function takes no argument.

    Thread Starter gstan07

    (@gstan07)

    I don’t know how many have such use cases but maybe it woul help to include such a thing on the next releases.
    Thanks for your answer.

    I have actually made a change to my local copy of WP_Fragment_Cache that can clear individual cache entries.

    I’ve added a new parameter to ::output(), that will store cache fragments with “absolute key names” – this will store fragments without the usual file name/path and line number, instead it will store it using the actual provided key name.

    Then I added a ::remove() function that will take an absolute key name and will remove the key from the cache.

    This is useful to hook into your theme for specific events (ie: when a comment is added, a post is changed etc.), without having to purge the whole cache (why update the whole cache when just a specific fragment changes?).

    I would commit it to the main code, but I’m afraid the quality of my documentation is not on par with mariuspass’.

    Plugin Author mariuspass

    (@mariuspass)

    I would commit it to the main code, but I’m afraid the quality of my documentation is not on par with mariuspass’.

    Please make a pull request on github repo.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘programatically delete cache entry’ is closed to new replies.