You can’t delete just one fragment, the purge function deletes all the fragments, also that function takes no argument.
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’.
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.