Skip to content

Commit

Permalink
Merge branch 'MDL-58658' of https://github.com/sk-unikent/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
danpoltawski committed Jun 6, 2017
2 parents 58a4dac + 761ac5a commit 1be1d5e
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cache/classes/loaders.php
Original file line number Diff line number Diff line change
Expand Up @@ -1077,7 +1077,7 @@ protected function static_acceleration_get($key) {
$result = $data;
}
}
if ($result) {
if ($result !== false) {
if ($this->perfdebug) {
cache_helper::record_cache_hit('** static acceleration **', $this->definition);
}
Expand Down Expand Up @@ -2162,4 +2162,4 @@ protected function use_static_acceleration() {
*/
class cache_request extends cache {
// This comment appeases code pre-checker ;) !
}
}
33 changes: 33 additions & 0 deletions cache/tests/cache_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -2177,6 +2177,39 @@ public function test_performance_debug() {
$startstats[$requestid]['stores']['cachestore_static']['sets']);
}

public function test_static_cache() {
global $CFG;
$this->resetAfterTest(true);
$CFG->perfdebug = 15;

// Create cache store with static acceleration.
$instance = cache_config_testing::instance();
$applicationid = 'phpunit/applicationperf';
$instance->phpunit_add_definition($applicationid, array(
'mode' => cache_store::MODE_APPLICATION,
'component' => 'phpunit',
'area' => 'applicationperf',
'simplekeys' => true,
'staticacceleration' => true,
'staticaccelerationsize' => 3
));

$application = cache::make('phpunit', 'applicationperf');

// Check that stores register sets.
$this->assertTrue($application->set('setMe1', 1));
$this->assertTrue($application->set('setMe2', 0));
$this->assertTrue($application->set('setMe3', array()));
$this->assertTrue($application->get('setMe1') !== false);
$this->assertTrue($application->get('setMe2') !== false);
$this->assertTrue($application->get('setMe3') !== false);

// Check that the static acceleration worked, even on empty arrays and the number 0.
$endstats = cache_helper::get_stats();
$this->assertEquals(0, $endstats[$applicationid]['stores']['** static acceleration **']['misses']);
$this->assertEquals(3, $endstats[$applicationid]['stores']['** static acceleration **']['hits']);
}

public function test_performance_debug_off() {
global $CFG;
$this->resetAfterTest(true);
Expand Down

0 comments on commit 1be1d5e

Please sign in to comment.