MDL-55628 Completion: Use simpledata for completion cache

The completion cache is currently not marked as simpledata. On the
course page it is frequently retrieved hundreds of times which results
in many calls to the slow unserialize function. By making a slight
change to the data format (using arrays instead of objects) we can
mark it as simpledata, which will avoid using unserialize.
This commit is contained in:
sam marshall
2016-08-22 17:15:09 +01:00
parent e90dfb32ae
commit 3226f39671
3 changed files with 30 additions and 28 deletions
+3 -3
View File
@@ -418,7 +418,7 @@ class core_completionlib_testcase extends advanced_testcase {
$result = $c->get_data($cm);
$this->assertEquals($sillyrecord, $result);
$cachevalue = $cache->get('314159_42');
$this->assertEquals($sillyrecord, $cachevalue[13]);
$this->assertEquals((array)$sillyrecord, $cachevalue[13]);
// 4. Current user, 'whole course', but from cache.
$result = $c->get_data($cm, true);
@@ -443,8 +443,8 @@ class core_completionlib_testcase extends advanced_testcase {
// Check the cache contents.
$cachevalue = $cache->get('314159_42');
$this->assertEquals($basicrecord, $cachevalue[13]);
$this->assertEquals((object)array('id'=>'0', 'coursemoduleid'=>14,
$this->assertEquals($basicrecord, (object)$cachevalue[13]);
$this->assertEquals(array('id' => '0', 'coursemoduleid' => 14,
'userid'=>314159, 'completionstate'=>0, 'viewed'=>0, 'timemodified'=>0),
$cachevalue[14]);
}