Permalink
Browse files

MDL-28463 conditionlib: 10 minutes lifetime of cached grades

  • Loading branch information...
1 parent 75d8d06 commit eaccd0d486d5da0ba125b72301fe6260c5c514f9 @marinaglancy marinaglancy committed Oct 29, 2013
Showing with 4 additions and 2 deletions.
  1. +4 −2 lib/conditionlib.php
View
6 lib/conditionlib.php
@@ -1139,10 +1139,12 @@ private function require_data() {
private function get_cached_grade_score($gradeitemid, $grabthelot=false, $userid=0) {
global $USER, $DB, $SESSION;
if ($userid==0 || $userid==$USER->id) {
- // For current user, go via cache in session
- if (empty($SESSION->gradescorecache) || $SESSION->gradescorecacheuserid!=$USER->id) {
+ // For current user, go via cache in session. Force reset it every 10 minutes.
+ if (empty($SESSION->gradescorecache) || $SESSION->gradescorecacheuserid!=$USER->id
+ || !isset($SESSION->gradescorecachereset) || $SESSION->gradescorecachereset+600<time()) {
$SESSION->gradescorecache = array();
$SESSION->gradescorecacheuserid = $USER->id;
+ $SESSION->gradescorecachereset = time();
}
if (!array_key_exists($gradeitemid, $SESSION->gradescorecache)) {
if ($grabthelot) {

0 comments on commit eaccd0d

Please sign in to comment.