mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 12:32:08 +02:00
MDL-39062 cache: persist keys now set properly
This commit is contained in:
parent
07bbbcf174
commit
10aabcb221
12
cache/classes/loaders.php
vendored
12
cache/classes/loaders.php
vendored
@ -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]);
|
||||
|
@ -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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user