diff --git a/admin/settings/server.php b/admin/settings/server.php index 461f06c06ad..7b11f4e7527 100644 --- a/admin/settings/server.php +++ b/admin/settings/server.php @@ -216,6 +216,16 @@ $temp->add(new admin_setting_configselect('memcachedpconn', new lang_string('mem array( '0' => new lang_string('no'), '1' => new lang_string('yes')))); */ + +$ADMIN->add('server', new admin_category('cache', new lang_string('caching', 'cache'))); +$ADMIN->add('cache', new admin_externalpage('cacheconfig', get_string('cacheconfig', 'cache'), new moodle_url('/cache/admin.php'))); +$ADMIN->add('cache', new admin_externalpage('cachetestperformance', get_string('testperformance', 'cache'), new moodle_url('/cache/testperformance.php'))); +foreach (get_plugin_list_with_file('cache', 'settings.php') as $plugin => $path) { + $settings = new admin_settingpage('cache_'.$plugin.'_settings', new lang_string('pluginname', 'cache_'.$plugin)); + require_once($path); + $ADMIN->add('cache', $settings); +} + $ADMIN->add('server', $temp); diff --git a/lang/en/admin.php b/lang/en/admin.php index b67ce851629..6a2c0c84e40 100644 --- a/lang/en/admin.php +++ b/lang/en/admin.php @@ -1072,3 +1072,13 @@ $string['webproxyinfo'] = 'Fill in following options if your Moodle server can n $string['xmlrpcrecommended'] = 'The xmlrpc extension is needed for hub communication, and useful for web services and Moodle networking'; $string['yuicomboloading'] = 'YUI combo loading'; $string['ziprequired'] = 'The Zip PHP extension is now required by Moodle, info-ZIP binaries or PclZip library are not used anymore.'; + + +$string['caching'] = 'Caching'; +$string['cachesettings'] = 'Cache settings'; +$string['cacherequest'] = 'Request cache'; +$string['cacherequesthelp'] = 'User specific cache that expires when the request is complete. Designed to replace areas where we are using the static stores.'; +$string['cachesession'] = 'Session cache'; +$string['cachesessionhelp'] = 'User specific cache that expires when the users session ends. Designed to aleviate session bloat/strain.'; +$string['cacheapplication'] = 'Application cache'; +$string['cacheapplicationhelp'] = ' Cached items are shared amoung all users and expire by a determined ttl.'; diff --git a/lang/en/cache.php b/lang/en/cache.php new file mode 100644 index 00000000000..39ca143c063 --- /dev/null +++ b/lang/en/cache.php @@ -0,0 +1,84 @@ + array( + 'mode' => cache_store::MODE_APPLICATION, + 'mappingsonly' => true, + ), + 'string' => array( + 'mode' => cache_store::MODE_APPLICATION, + 'component' => 'core', + 'area' => 'string', + 'persistent' => true, + 'persistentmaxsize' => 3 + ), + 'databasemeta' => array( + 'mode' => cache_store::MODE_APPLICATION, + 'requireidentifiers' => array( + 'dbfamily' + ), + 'persistent' => true, + 'persistentmaxsize' => 2 + ), + 'config' => array( + 'mode' => cache_store::MODE_APPLICATION, + 'persistent' => true + ), + // Event invalidation cache + 'eventinvalidation' => array( + 'mode' => cache_store::MODE_APPLICATION, + 'persistent' => true, + 'requiredataguarantee' => true + ) +); diff --git a/lib/moodlelib.php b/lib/moodlelib.php index 7e2eebe355c..83db6b7b5e5 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -1498,6 +1498,8 @@ function purge_all_caches() { get_string_manager()->reset_caches(); textlib::reset_caches(); + cache_helper::purge_all(); + // purge all other caches: rss, simplepie, etc. remove_dir($CFG->cachedir.'', true); @@ -7906,6 +7908,7 @@ function get_core_subsystems() { 'block' => 'blocks', 'blog' => 'blog', 'bulkusers' => NULL, + 'cache' => 'cache', 'calendar' => 'calendar', 'cohort' => 'cohort', 'condition' => NULL, @@ -8004,6 +8007,7 @@ function get_plugin_types($fullpaths=true) { 'qformat' => 'question/format', 'plagiarism' => 'plagiarism', 'tool' => $CFG->admin.'/tool', + 'cache' => 'cache/stores', 'theme' => 'theme', // this is a bit hacky, themes may be in $CFG->themedir too ); @@ -10425,6 +10429,37 @@ function get_performance_info() { $info['txt'] .= 'rcache: '. "{$rcache->hits}/{$rcache->misses} "; }*/ + + if ($stats = cache_helper::get_stats()) { + $html = ''; + $html .= 'Caches interaction by definition then store'; + $text = 'Caches used (hits/misses/sets): '; + $hits = 0; + $misses = 0; + $sets = 0; + foreach ($stats as $definition => $stores) { + $html .= ''.$definition.''; + $text .= "$definition {"; + foreach ($stores as $store => $data) { + $hits += $data['hits']; + $misses += $data['misses']; + $sets += $data['sets']; + $text .= "$store($data[hits]/$data[misses]/$data[sets]) "; + $html .= "$store: $data[hits] / $data[misses] / $data[sets]"; + } + $text .= '} '; + } + $html .= "Total Hits / Misses / Sets : $hits / $misses / $sets"; + $html .= ' '; + $info['cachesused'] = "$hits / $misses / $sets"; + $info['html'] .= $html; + $info['txt'] .= $text.'. '; + } else { + $info['cachesused'] = '0 / 0 / 0'; + $info['html'] .= 'Caches used (hits/misses/sets): 0/0/0'; + $info['txt'] .= 'Caches used (hits/misses/sets): 0/0/0 '; + } + $info['html'] = '