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.

[php]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’;
empty_dir($cache_dir);
die("Cache Cleared");
}[/php]

Or more like AC way

[php]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");
}[/php]

And call it with ?cc in browser.

Leave a Reply