Permalink
Browse files

MDL-38165 cache: fixed up application event purging

  • Loading branch information...
1 parent b6c86be commit 43394c5114cd3dcf6a06a5e49776ad203059c026 Sam Hemelryk committed Feb 27, 2013
Showing with 11 additions and 3 deletions.
  1. +11 −3 cache/classes/loaders.php
@@ -1094,22 +1094,30 @@ public function __construct(cache_definition $definition, cache_store $store, $l
$cache = cache::make('core', 'eventinvalidation');
$events = $cache->get_many($definition->get_invalidation_events());
$todelete = array();
+ $purgeall = false;
// Iterate the returned data for the events.
foreach ($events as $event => $keys) {
if ($keys === false) {
- // There are no keys.
+ // No data to be invalidated yet.
continue;
}
// Look at each key and check the timestamp.
foreach ($keys as $key => $timestamp) {
// If the timestamp of the event is more than or equal to the last invalidation (happened between the last
// invalidation and now)then we need to invaliate the key.
if ($timestamp >= $lastinvalidation) {
- $todelete[] = $key;
+ if ($key === 'purged') {
+ $purgeall = true;
+ break;
+ } else {
+ $todelete[] = $key;
+ }
}
}
}
- if (!empty($todelete)) {
+ if ($purgeall) {
+ $this->purge();
+ } else if (!empty($todelete)) {
$todelete = array_unique($todelete);
$this->delete_many($todelete);
}

0 comments on commit 43394c5

Please sign in to comment.