How to invalidate custom cache


in reference to this old forum topic, I have another question about the cache:

I have set c::set('cache', true) in my config file for my site. As I have multiple items which contents could change through to other rules I have set up, I would like to know if it is possible to delete the cache on purpose. Maybe even when data is saved on another page of the whole site.

Or could I set IDs for the cache, which I can than delete without removing all of the cached contents?
Is it possible to remove multiple cached fields by setting up a prefix?

Thanks for your help.

If you use the file cache driver (which is default) it’s an all-or-nothing thing.

If you’ld like to flush the cache yourself, you can use cache::flush(). But, as I said, this will clear the entire cache. This is by design since it cannot know if the thing you just changed isn’t pulled into another page somehow.

If you would like to have more control, you could try to setup your “own” cache logic by indeed following the explanations in the “old forum topic” :-).