Skip to content

Commit

Permalink
MDL-45678 cache: renamed new cache and better comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam Hemelryk committed Jul 7, 2014
1 parent 6b6affe commit bfe4417
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lang/en/cache.php
Expand Up @@ -46,7 +46,7 @@
$string['cachedef_databasemeta'] = 'Database meta information';
$string['cachedef_eventinvalidation'] = 'Event invalidation';
$string['cachedef_externalbadges'] = 'External badges for particular user';
$string['cachedef_get_suspended_userids'] = 'List of suspended user identifiers per course';
$string['cachedef_suspended_userids'] = 'List of suspended users per course';
$string['cachedef_gradecondition'] = 'User grades cached for evaluating conditional availability';
$string['cachedef_groupdata'] = 'Course group information';
$string['cachedef_htmlpurifier'] = 'HTML Purifier - cleaned content';
Expand Down
4 changes: 2 additions & 2 deletions lib/accesslib.php
Expand Up @@ -7460,15 +7460,15 @@ function extract_suspended_users($context, &$users, $ignoreusers=array()) {
* or enrolment has expired or not started.
*
* @param context $context context in which user enrolment is checked.
* @param bool $context Enable or disable (default) the request cache
* @param bool $usecache Enable or disable (default) the request cache
* @return array list of suspended user id's.
*/
function get_suspended_userids(context $context, $usecache = false) {
global $DB;

// Check the cache first for performance reasons if enabled.
if ($usecache) {
$cache = cache::make('core', 'get_suspended_userids');
$cache = cache::make('core', 'suspended_userids');
$susers = $cache->get($context->id);
if ($susers !== false) {
return $susers;
Expand Down
5 changes: 3 additions & 2 deletions lib/db/caches.php
Expand Up @@ -223,8 +223,9 @@
'simpledata' => true
),

// For the function get_suspended_userids() in core_access.
'get_suspended_userids' => array(
// Caches suspended userids by course.
// The key is the courseid, the value is an array of user ids.
'suspended_userids' => array(
'mode' => cache_store::MODE_REQUEST,
'simplekeys' => true,
'simpledata' => true,
Expand Down
2 changes: 1 addition & 1 deletion lib/enrollib.php
Expand Up @@ -1407,7 +1407,7 @@ public function update_user_enrol(stdClass $instance, $userid, $status = NULL, $
context_course::instance($instance->courseid)->mark_dirty(); // reset enrol caches

// Invalidate core_access cache for get_suspended_userids.
cache_helper::invalidate_by_definition('core', 'get_suspended_userids', array(), array($instance->courseid));
cache_helper::invalidate_by_definition('core', 'suspended_userids', array(), array($instance->courseid));

// Trigger event.
$event = \core\event\user_enrolment_updated::create(
Expand Down

0 comments on commit bfe4417

Please sign in to comment.