diff --git a/admin/tool/mobile/classes/api.php b/admin/tool/mobile/classes/api.php index 6f6cb71fe97..2671146a60f 100644 --- a/admin/tool/mobile/classes/api.php +++ b/admin/tool/mobile/classes/api.php @@ -45,6 +45,13 @@ class api { global $CFG; require_once($CFG->libdir . '/adminlib.php'); + // Check if we can return this from cache. + $cache = \cache::make('tool_mobile', 'plugininfo'); + $pluginsinfo = $cache->get('mobileplugins'); + if ($pluginsinfo !== false) { + return (array)$pluginsinfo; + } + $pluginsinfo = []; $plugintypes = core_component::get_plugin_types(); @@ -56,7 +63,7 @@ class api { $component = $plugintype . '_' . $plugin; $version = get_component_version($component); - require_once("$path/db/mobile.php"); + require("$path/db/mobile.php"); foreach ($addons as $addonname => $addoninfo) { $plugininfo = array( 'component' => $component, @@ -79,6 +86,9 @@ class api { } } } + + $cache->set('mobileplugins', $pluginsinfo); + return $pluginsinfo; } diff --git a/admin/tool/mobile/db/caches.php b/admin/tool/mobile/db/caches.php new file mode 100644 index 00000000000..6cfcca78051 --- /dev/null +++ b/admin/tool/mobile/db/caches.php @@ -0,0 +1,34 @@ +. + +/** + * Mobile cache definitions. + * + * @package tool_mobile + * @copyright 2017 Skylar Kelty + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +defined('MOODLE_INTERNAL') || die; + +$definitions = array( + 'plugininfo' => array( + 'mode' => cache_store::MODE_APPLICATION, + 'simplekeys' => true, + 'staticacceleration' => true, + 'staticaccelerationsize' => 1 + ) +); diff --git a/admin/tool/mobile/lang/en/tool_mobile.php b/admin/tool/mobile/lang/en/tool_mobile.php index 56a13605089..1c2bf12fe7d 100644 --- a/admin/tool/mobile/lang/en/tool_mobile.php +++ b/admin/tool/mobile/lang/en/tool_mobile.php @@ -23,3 +23,4 @@ */ $string['pluginname'] = 'Moodle Mobile tools'; +$string['cachedef_plugininfo'] = 'This stores the list of plugins with mobile addons';