MDL-63101 cache: Improve accuracy of cache event invalidation

This commit is contained in:
Andrew Nicols
2018-08-27 14:43:42 +08:00
parent 8df868e9e0
commit 0a197875df
5 changed files with 201 additions and 27 deletions
+10 -2
View File
@@ -240,6 +240,7 @@ class cache_helper {
$invalidationeventset = false;
$factory = cache_factory::instance();
$inuse = $factory->get_caches_in_use();
$purgetoken = null;
foreach ($instance->get_definitions() as $name => $definitionarr) {
$definition = cache_definition::load($name, $definitionarr);
if ($definition->invalidates_on_event($event)) {
@@ -266,8 +267,11 @@ class cache_helper {
$data = array();
}
// Add our keys to them with the current cache timestamp.
if (null === $purgetoken) {
$purgetoken = cache::get_purge_token(true);
}
foreach ($keys as $key) {
$data[$key] = cache::now();
$data[$key] = $purgetoken;
}
// Set that data back to the cache.
$cache->set($event, $data);
@@ -315,6 +319,7 @@ class cache_helper {
$invalidationeventset = false;
$factory = cache_factory::instance();
$inuse = $factory->get_caches_in_use();
$purgetoken = null;
foreach ($instance->get_definitions() as $name => $definitionarr) {
$definition = cache_definition::load($name, $definitionarr);
if ($definition->invalidates_on_event($event)) {
@@ -338,8 +343,11 @@ class cache_helper {
// Get the event invalidation cache.
$cache = cache::make('core', 'eventinvalidation');
// Create a key to invalidate all.
if (null === $purgetoken) {
$purgetoken = cache::get_purge_token(true);
}
$data = array(
'purged' => cache::now()
'purged' => $purgetoken,
);
// Set that data back to the cache.
$cache->set($event, $data);