]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-7346 Changed enablerecordcache to be a limit for the size of cache, not just...
authorsam_marshall <sam_marshall>
Fri, 3 Nov 2006 17:29:15 +0000 (17:29 +0000)
committersam_marshall <sam_marshall>
Fri, 3 Nov 2006 17:29:15 +0000 (17:29 +0000)
admin/settings/server.php
lang/en_utf8/admin.php
lib/dmllib.php

index b01eabaa9503886bdb494c415e73898336d92d86..a634dc4fa022fbfc9fe0e3d80c2acbb2ccee3265 100644 (file)
@@ -177,7 +177,7 @@ $ADMIN->add('server', new admin_externalpage('phpinfo', get_string('phpinfo'), "
 
 // "performance" settingpage
 $temp = new admin_settingpage('performance', get_string('performance', 'admin'));
-$temp->add(new admin_setting_configcheckbox('enablerecordcache', get_string('enablerecordcache', 'admin'), get_string('configenablerecordcache', 'admin'), 1));
+$temp->add(new admin_setting_configtext('enablerecordcache', get_string('enablerecordcache', 'admin'), get_string('configenablerecordcache', 'admin'), 50));
 $ADMIN->add('server', $temp);
 
 if (file_exists("$CFG->dirroot/$CFG->admin/mysql/frame.php")) {
index 76a8c3a0f02ba8a40b177bb29acf9e5c347accd1..cf4cd00ea9b7e9030c921b244968b52fffdb00c5 100644 (file)
@@ -75,7 +75,7 @@ $string['configeditorfontlist'] = 'Select the fonts that should appear in the ed
 $string['configenableajax'] = 'This setting allows you to control the use of AJAX (advanced client/server interfaces using Javascript) across the whole site.  With this setting enabled users can sill make a choice in their profile, otherwise AJAX is disabled for everybody.';
 $string['configenablecourserequests'] = 'This will allow any user to request a course be created.';
 $string['configenableglobalsearch'] = 'This setting enables global text searching in resources and activities, it is not compatible with PHP 4.';
-$string['configenablerecordcache'] = 'If you enable this, some in-memory caching will be performed while retrieving info from database. This means that your database throughput will be better but, on the other hand, your web server memory requirements will be slightly increased. Generally we recommend this to be enabled unless your server is low on memory. Some processes may choose to override this setting where the developer is certain of a performance increase.';
+$string['configenablerecordcache'] = 'If you set this to a number higher than 0, some in-memory caching will be performed while retrieving info from the database. This means that your database throughput will be better but, on the other hand, your web server memory requirements will be slightly increased. Generally we recommend values of around 50 unless your server is low on memory. Some processes may choose to override this setting where the developer is certain of a performance increase.';
 $string['configenablerssfeeds'] = 'This switch will enable RSS feeds from across the site.  To actually see any change you will need to enable RSS feeds in the individual modules too - go to the Modules settings under Admin Configuration.';
 $string['configenablerssfeedsdisabled'] = 'It is not available because RSS feeds are disabled in all the Site. To enable them, go to the Variables settings under Admin Configuration.';
 $string['configenablestats'] = 'If you choose \'yes\' here, Moodle\'s cronjob will process the logs and gather some statistics.  Depending on the amount of traffic on your site, this can take awhile. If you enable this, you will be able to see some interesting graphs and statistics about each of your courses, or on a sitewide basis.';
index e95d236edc78bb2c593ea77088b247b14b9b1ebf..84ce6a1126f2a1d60fb9a3718aedeca18b30ce14 100644 (file)
@@ -40,6 +40,7 @@
 $empty_rs_cache = array();   // Keeps copies of the recordsets used in one invocation
 $metadata_cache = array();   // Keeps copies of the MetaColumns() for each table used in one invocations
 $record_cache = array();     // Keeps copies of all simple get_record results from one invocation
+$record_cache_size = 0;      // Count of get_record results stored in this invocation
 
 /// FUNCTIONS FOR DATABASE HANDLING  ////////////////////////////////
 
@@ -371,7 +372,7 @@ function count_records_sql($sql) {
  */
 function get_record($table, $field1, $value1, $field2='', $value2='', $field3='', $value3='', $fields='*') {
     
-    global $CFG, $record_cache;
+    global $CFG, $record_cache, $record_cache_count;
     
     // Check to see whether this record is eligible for caching (fields=*, only condition is id)
     $docache = false;
@@ -388,8 +389,12 @@ function get_record($table, $field1, $value1, $field2='', $value2='', $field3=''
     $record = get_record_sql('SELECT '.$fields.' FROM '. $CFG->prefix . $table .' '. $select);
     
     // If we're caching records, store this one (supposing we got something - we don't cache failures)
-    if (!empty($CFG->enablerecordcache) && $record && $docache) {
+    if ($record && $docache && $record_cache_count<$CFG->enablerecordcache) {
         $record_cache[$table][$value1] = $record;
+        // We only cache records up to a limit. This is to prevent memory usage becoming 
+        // unreasonably high for pages which do things like, load every student record in
+        // a course, or some such.
+        $record_cache_count++;
     }
 
     return $record;
@@ -2020,4 +2025,4 @@ function db_update_lobs ($table, $sqlcondition, &$clobs, &$blobs) {
     return $status;
 }
 
-?>
+?>
\ No newline at end of file