mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
Merge branch 'MDL-59427-master' of https://github.com/sammarshallou/moodle
This commit is contained in:
commit
f75b93c9d3
9
cache/classes/factory.php
vendored
9
cache/classes/factory.php
vendored
@ -335,6 +335,15 @@ class cache_factory {
|
||||
return $this->cachesfromdefinitions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all adhoc caches that have been used within this request.
|
||||
*
|
||||
* @return cache_store[] Caches currently in use
|
||||
*/
|
||||
public function get_adhoc_caches_in_use() {
|
||||
return $this->cachesfromparams;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a cache config instance with the ability to write if required.
|
||||
*
|
||||
|
3
cache/classes/helper.php
vendored
3
cache/classes/helper.php
vendored
@ -484,6 +484,9 @@ class cache_helper {
|
||||
foreach ($config->get_all_stores() as $store) {
|
||||
self::purge_store($store['name'], $config);
|
||||
}
|
||||
foreach ($factory->get_adhoc_caches_in_use() as $cache) {
|
||||
$cache->purge();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
10
cache/tests/cache_test.php
vendored
10
cache/tests/cache_test.php
vendored
@ -1730,6 +1730,16 @@ class core_cache_testcase extends advanced_testcase {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that ad-hoc caches are correctly purged with a purge_all call.
|
||||
*/
|
||||
public function test_purge_all_with_adhoc_caches() {
|
||||
$cache = \cache::make_from_params(\cache_store::MODE_REQUEST, 'core_cache', 'test');
|
||||
$cache->set('test', 123);
|
||||
cache_helper::purge_all();
|
||||
$this->assertFalse($cache->get('test'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that the default stores all support searching.
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user