public static function purge_all($usewriter = false) {
        $factory = cache_factory::instance();
        $config = $factory->create_config_instance($usewriter);
        foreach ($config->get_all_stores() as $store) {
            self::purge_store($store['name'], $config);
        }
        foreach ($factory->get_adhoc_caches_in_use() as $cache) {
            $cache->purge();
        }
    }