MDL-72991 Course: Partial course cache rebuild

When updating/deleting a section/module, the system now only
invalidate of the element (section/module), not the whole course cache
Also, the system now only recalculate the cache for element (section/module)
if necessary, not the whole course cache

Move module/section purging to course_modinfo:
  + course_modinfo::purge_course_section_cache_by_id was created to purge section by id
  + course_modinfo::purge_course_section_cache_by_number was created to purge section by number
  + course_modinfo::purge_course_module_cache was created to purge module
This commit is contained in:
Dongsheng Cai
2022-03-17 15:34:01 +07:00
committed by Huong Nguyen
parent 967d9b2546
commit f97b86e841
17 changed files with 458 additions and 181 deletions
+41
View File
@@ -3687,4 +3687,45 @@ function print_grade_plugin_selector($plugin_info, $active_type, $active_plugin,
// only one option - no plugin selector needed
return '';
}
/**
* Purge the cache of a course section.
*
* $sectioninfo must have following attributes:
* - course: course id
* - section: section number
*
* @param object $sectioninfo section info
* @return void
* @deprecated since Moodle 4.0. Please use {@link course_modinfo::purge_course_section_cache_by_id()}
* or {@link course_modinfo::purge_course_section_cache_by_number()} instead.
*/
function course_purge_section_cache(object $sectioninfo): void {
debugging(__FUNCTION__ . '() is deprecated. ' .
'Please use course_modinfo::purge_course_section_cache_by_id() ' .
'or course_modinfo::purge_course_section_cache_by_number() instead.',
DEBUG_DEVELOPER);
$sectionid = $sectioninfo->section;
$courseid = $sectioninfo->course;
course_modinfo::purge_course_section_cache_by_id($courseid, $sectionid);
}
/**
* Purge the cache of a course module.
*
* $cm must have following attributes:
* - id: cmid
* - course: course id
*
* @param cm_info|stdClass $cm course module
* @return void
* @deprecated since Moodle 4.0. Please use {@link course_modinfo::purge_course_module_cache()} instead.
*/
function course_purge_module_cache($cm): void {
debugging(__FUNCTION__ . '() is deprecated. ' . 'Please use course_modinfo::purge_course_module_cache() instead.',
DEBUG_DEVELOPER);
$cmid = $cm->id;
$courseid = $cm->course;
course_modinfo::purge_course_module_cache($courseid, $cmid);
}
}