// "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")) {
$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.';
$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 ////////////////////////////////
*/
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;
$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;
return $status;
}
-?>
+?>
\ No newline at end of file