diff --git a/cache/classes/loaders.php b/cache/classes/loaders.php index 6f4e680e29a..da8fe6758bf 100644 --- a/cache/classes/loaders.php +++ b/cache/classes/loaders.php @@ -117,6 +117,8 @@ class cache implements cache_loader { /** * An array containing just the keys being used in the persist cache. * This seems redundant perhaps but is used when managing the size of the persist cache. + * Items are added to the end of the array and the when we need to reduce the size of the cache we use the + * key that is first on this array. * @var array */ private $persistkeys = array(); @@ -965,6 +967,15 @@ class cache implements cache_loader { if ($this->perfdebug) { cache_helper::record_cache_hit('** static persist **', $this->definition->get_id()); } + if ($this->persistmaxsize > 1 && $this->persistcount > 1) { + // Check to see if this is the last item on the persist keys array. + if (end($this->persistkeys) !== $key) { + // It isn't the last item. + // Move the item to the end of the array so that it is last to be removed. + unset($this->persistkeys[$key]); + $this->persistkeys[$key] = $key; + } + } return $result; } else { if ($this->perfdebug) { @@ -989,6 +1000,7 @@ class cache implements cache_loader { $this->persistcache[$key] = $data; if ($this->persistmaxsize !== false) { $this->persistcount++; + $this->persistkeys[$key] = $key; if ($this->persistcount > $this->persistmaxsize) { $dropkey = array_shift($this->persistkeys); unset($this->persistcache[$dropkey]); diff --git a/lib/db/caches.php b/lib/db/caches.php index 44e7e376e78..0498fc4c1af 100644 --- a/lib/db/caches.php +++ b/lib/db/caches.php @@ -30,12 +30,13 @@ $definitions = array( // Used to store processed lang files. // The keys used are the component of the string file. + // The persistent max size has been based upon student access of the site. 'string' => array( 'mode' => cache_store::MODE_APPLICATION, 'simplekeys' => true, 'simpledata' => true, 'persistent' => true, - 'persistentmaxsize' => 3 + 'persistentmaxsize' => 30 ), // Used to store database meta information. @@ -48,7 +49,7 @@ $definitions = array( 'dbfamily' ), 'persistent' => true, - 'persistentmaxsize' => 2 + 'persistentmaxsize' => 15 ), // Event invalidation cache. @@ -78,7 +79,7 @@ $definitions = array( // HTML Purifier cache // This caches the html purifier cleaned text. This is done because the text is usually cleaned once for every user - // and context combo. Text caching handles caching for the combonation, this cache is responsible for caching the + // and context combo. Text caching handles caching for the combination, this cache is responsible for caching the // cleaned text which is shareable. 'htmlpurifier' => array( 'mode' => cache_store::MODE_APPLICATION, diff --git a/version.php b/version.php index bbe0cbeb5de..2e8d2210516 100644 --- a/version.php +++ b/version.php @@ -29,7 +29,7 @@ defined('MOODLE_INTERNAL') || die(); -$version = 2012120305.02; // 20121203 = branching date YYYYMMDD - do not modify! +$version = 2012120305.03; // 20121203 = branching date YYYYMMDD - do not modify! // RR = release increments - 00 in DEV branches // .XX = incremental changes