Cache flush on demand

Is there any way to flush the COutputCache (via APC) on demand?

eg. add ?flush=1 to end of URL, then detect that somewhere and do the flush.

My initial thought is something like this

class FlushableCache extends COutputCache


  public function init()


    if (isset($_GET['flush']) && $_GET['flush'])





The set your application to use FlushableCache instead of COuputCache.

There might be another way to do it, but this is the only way I could think up. I didn’t see anything where you could attach a behavior to the controller or the application. That might be the preferable way, as to not add another layer of objects somewhere.

You could also introduce a base controller and put it in the init() method there. A base controller comes in handy in many situations, so i’d consider it good practice anyway.

class MyBaseController extends CController { /* ... */ }.

class SomeController extends MyBaseController { /* ... */ } 

The reason I did not suggest this was because it would required more code changes than changing the output cache handler if the system wasn’t already designed in this manner.