Clearing Activacollab 3.x cache through script

With upgrading to AC3 the old clear_cache_by_pattern(“*”) stopped working. There’s option at admin but i wanted a more shortcut way to clear cache, just by entering a url in browser window. So i did put this code at the top of script function in controller and called it when i needed to clear cache.

If you wanted to delete selected cache. There are different methods to clear different set of cache. For example, using Router::cleanUpCache(true); for clearing Router cache.

A selective and more custom way.

if(isset($_GET['cc']))	{
	DB::execute("TRUNCATE TABLE  `acx_activity_logs`");
	DB::execute("TRUNCATE TABLE  `acx_object_contexts`");
	DB::execute("TRUNCATE TABLE  `acx_routing_cache`");
	$cache_dir = dirname(ROOT) . '/cache';
	die("Cache Cleared");

Or more like AC way

if(isset($_GET['cc']))	{
	if(function_exists('cache_clear')) {
	  cache_clear(true); // activeCollab 3.2 or older
	} else {
	  AngieApplication::cache()->clear(); // activeCollab 3.3 or up
	} // if
	die("Cache Cleared");

And call it with ?cc in browser.

Leave a Reply

Your email address will not be published. Required fields are marked *