Skip to content

Commit

Permalink
MDL-58590 mobile: Cache mobile-supporting plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
sk-unikent committed Apr 20, 2017
1 parent 0714bcb commit 30fccfc
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 2 deletions.
12 changes: 11 additions & 1 deletion admin/tool/mobile/classes/api.php
Expand Up @@ -58,6 +58,13 @@ public static function get_plugins_supporting_mobile() {
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();

Expand All @@ -69,7 +76,7 @@ public static function get_plugins_supporting_mobile() {
$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,
Expand All @@ -92,6 +99,9 @@ public static function get_plugins_supporting_mobile() {
}
}
}

$cache->set('mobileplugins', $pluginsinfo);

return $pluginsinfo;
}

Expand Down
34 changes: 34 additions & 0 deletions admin/tool/mobile/db/caches.php
@@ -0,0 +1,34 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Mobile cache definitions.
*
* @package tool_mobile
* @copyright 2017 Skylar Kelty <S.Kelty@kent.ac.uk>
* @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
)
);
1 change: 1 addition & 0 deletions admin/tool/mobile/lang/en/tool_mobile.php
Expand Up @@ -26,6 +26,7 @@
$string['androidappid_desc'] = 'This setting may be left as default unless you have a custom Android app.';
$string['autologinkeygenerationlockout'] = 'Auto-login key generation is blocked because of too many requests within an hour.';
$string['autologinnotallowedtoadmins'] = 'Auto-login is not allowed for site admins.';
$string['cachedef_plugininfo'] = 'This stores the list of plugins with mobile addons';
$string['clickheretolaunchtheapp'] = 'Click here if the app does not open automatically.';
$string['configmobilecssurl'] = 'A CSS file to customise your mobile app interface.';
$string['customlangstrings'] = 'Custom language strings';
Expand Down
2 changes: 1 addition & 1 deletion admin/tool/mobile/version.php
Expand Up @@ -23,7 +23,7 @@
*/

defined('MOODLE_INTERNAL') || die();
$plugin->version = 2016120505; // The current plugin version (Date: YYYYMMDDXX).
$plugin->version = 2017041200; // The current plugin version (Date: YYYYMMDDXX).
$plugin->requires = 2016112900; // Requires this Moodle version.
$plugin->component = 'tool_mobile'; // Full name of the plugin (used for diagnostics).
$plugin->dependencies = array(
Expand Down

0 comments on commit 30fccfc

Please sign in to comment.