Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-34397

Develop course structure caching

    XMLWordPrintable

    Details

    • Affected Branches:
      MOODLE_23_STABLE, MOODLE_26_STABLE
    • Epic Name:
      Course caching
    • Story Points:
      100
    • Sprint:
      BACKEND Sprint 4

      Description

      The main goal of this change is to move the content of the fields course.modinfo and course.sectioncache to MUC.

      More complete list of changes:

      • classes course_modinfo, cm_info, section_cache no longer extend stdClass and all properties are read-only. No more deprecated but still used everywhere public properties - all properties have getters and you can legally use either $modinfo->cms or $modinfo->get_cms()
      • classes cm_info and section_cache no longer calculate any data on initialisation and only calculate it when it is needed (saves extra DB queries when conditional availability is enabled).
      • database fields course.modinfo and course.sectioncache are removed, new application cache core/coursemodinfo stores this information.
      • course cache now additionally stores some fields from 'course' table such as format, enableavailability, groupmode, etc. that are necessary when calculating availability or additional section fields
      • new field course.cacherev added to table course and it is incremented every time the course cache is reset. Object in cache stores the value of cacherev at the moment when cache was built. This allows to avoid race conditions when course cache was simultaneously reset and rebuild by different people and became corrupt.

      Main changes for users

      • less db queries, less RAM usage on heavy pages such as "My courses"
      • much less probability of corrupt course cache (hopefully none at all)
      • "Purge all caches" purges course caches as well
      • Every core upgrade purges course caches

      Notes for developers

      • Do not access removed fields course.modinfo and course.sectioncache
      • If you need the raw user-independed information - call get_fast_modinfo($courseorid, -1)
      • Do not try to overwrite/append properties of course_modinfo or cm_info
      • do not hint any of those classes as stdClass in function arguments or you'll hit fatal error
      • Enjoy IDE hints for the properties and methods in modinfo classes
      • When calling get_fast_modinfo() for the list of courses make sure to retrieve/pass field cacherev. Otherwise an extra db query will be made. Not necessary when calling get_fast_modinfo() for current course. Most of core API functions returning list of courses will return you this field anyway.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                3 Vote for this issue
                Watchers:
                13 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: