Example #1
0
     $factory = cache_factory::instance();
     $definition = $factory->create_definition($component, $area);
     if ($definition->has_required_identifiers()) {
         // We will have to purge the stores used by this definition.
         cache_helper::purge_stores_used_by_definition($component, $area);
     } else {
         // Alrighty we can purge just the data belonging to this definition.
         cache_helper::purge_by_definition($component, $area);
     }
     redirect($PAGE->url, get_string('purgedefinitionsuccess', 'cache'), 5);
     break;
 case 'purgestore':
 case 'purge':
     // Purge a store cache.
     $store = required_param('store', PARAM_TEXT);
     cache_helper::purge_store($store);
     redirect($PAGE->url, get_string('purgestoresuccess', 'cache'), 5);
     break;
 case 'newlockinstance':
     // Adds a new lock instance.
     $lock = required_param('lock', PARAM_ALPHANUMEXT);
     $mform = cache_administration_helper::get_add_lock_form($lock);
     if ($mform->is_cancelled()) {
         redirect($PAGE->url);
     } else {
         if ($data = $mform->get_data()) {
             $factory = cache_factory::instance();
             $config = $factory->create_config_instance(true);
             $name = $data->name;
             $data = cache_administration_helper::get_lock_configuration_from_data($lock, $data);
             $config->add_lock_instance($name, $lock, $data);