From 8f8517ec1f3aaf953f9a6ace6e107f91a19f13d5 Mon Sep 17 00:00:00 2001 From: David Monllao Date: Fri, 18 Mar 2016 10:02:05 +0800 Subject: [PATCH] MDL-53543 cache: Invalidate grade_categories by event We can switch the cache to session level if we are able to purge different users caches, not only the one that belongs to the user updating a grade category. --- lib/db/caches.php | 7 +++++-- lib/grade/grade_category.php | 3 +-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/db/caches.php b/lib/db/caches.php index 6dbdc1e2fba..f5d59488af5 100644 --- a/lib/db/caches.php +++ b/lib/db/caches.php @@ -271,10 +271,13 @@ $definitions = array( 'staticaccelerationsize' => 3 ), - // Grade categories. Stored at request level as invalidation is very aggressive. + // Grade categories. Stored at session level as invalidation is very aggressive. 'grade_categories' => array( - 'mode' => cache_store::MODE_REQUEST, + 'mode' => cache_store::MODE_SESSION, 'simplekeys' => true, + 'invalidationevents' => array( + 'changesingradecategories', + ) ), // Store temporary tables information. diff --git a/lib/grade/grade_category.php b/lib/grade/grade_category.php index 13d15c4b425..2723f7079a1 100644 --- a/lib/grade/grade_category.php +++ b/lib/grade/grade_category.php @@ -2691,7 +2691,6 @@ class grade_category extends grade_object { * @return void */ public static function clean_record_set() { - $cache = cache::make('core', 'grade_categories'); - $cache->purge(); + cache_helper::purge_by_event('changesingradecategories'); } }