]> git.mjollnir.org Git - moodle.git/commit
get_my_courses() and get_user_courses_bycap() field handling and caching
authormartinlanghoff <martinlanghoff>
Wed, 19 Sep 2007 07:04:59 +0000 (07:04 +0000)
committermartinlanghoff <martinlanghoff>
Wed, 19 Sep 2007 07:04:59 +0000 (07:04 +0000)
commit352f6f74fc62d4ec5099d71c2bd6580171559c88
tree220fb5fa7598122ca5ca2cdc265aa7fddf4c4cdc
parent2e059c7709c5b847154462252c62499b8e35a067
get_my_courses() and get_user_courses_bycap() field handling and caching

- Field handling moves back to get_my_courses() and now we have
  almost all the fields that the old get_my_courses() did
  (except for summary, which is *huge*) so get_my_courses() asks
  for a lot of fields, but the get_user_courses_bycap() defaults
  are _much_ leaner now.

  I think this makes sense ;-)

- get_my_courses() now caches the course ids for the currently logged in
  user in $USER->mycourses -- as a _string_. This is magnitudes more efficient
  than having it as an array.

The cache makes a difference, but it's not very visible on
normal pageloads (with my courses block, for example).

However, over 100 iterations, for a user with 50 enrolments in a site
with 6K courses, we go from 4.3s to 0.6s. And the DB queries are *cheap*.

            $tt = microtime(true);
            for($n=0;$n<100;$n++) {
                get_my_courses($USER->id, 'sortorder ASC');
            }
            error_log("took " .  (microtime(true) - $tt));
lib/accesslib.php
lib/datalib.php