mirror of
https://github.com/moodle/moodle.git
synced 2025-04-20 07:56:06 +02:00
MDL-65394 portfolio: add cache for portfolio_add_button
This commit is contained in:
parent
8353770743
commit
76fbbf7e7e
@ -65,6 +65,7 @@ $string['cachedef_observers'] = 'Event observers';
|
||||
$string['cachedef_plugin_functions'] = 'Plugins available callbacks';
|
||||
$string['cachedef_plugin_manager'] = 'Plugin info manager';
|
||||
$string['cachedef_presignup'] = 'Pre sign-up data for particular unregistered user';
|
||||
$string['cachedef_portfolio_add_button_portfolio_instances'] = 'Portfolio instances for portfolio_add_button class';
|
||||
$string['cachedef_postprocessedcss'] = 'Post processed CSS';
|
||||
$string['cachedef_tagindexbuilder'] = 'Search results for tagged items';
|
||||
$string['cachedef_questiondata'] = 'Question definitions';
|
||||
|
@ -391,4 +391,13 @@ $definitions = array(
|
||||
'simplekeys' => true,
|
||||
'simpledata' => true,
|
||||
),
|
||||
|
||||
// Cache the list of portfolio instances for the logged in user
|
||||
// in the portfolio_add_button constructor to avoid loading the
|
||||
// same data multiple times.
|
||||
'portfolio_add_button_portfolio_instances' => [
|
||||
'mode' => cache_store::MODE_REQUEST,
|
||||
'simplekeys' => true,
|
||||
'staticacceleration' => true
|
||||
],
|
||||
);
|
||||
|
@ -117,7 +117,14 @@ class portfolio_add_button {
|
||||
debugging('Building portfolio add button while portfolios is disabled. This code can be optimised.', DEBUG_DEVELOPER);
|
||||
}
|
||||
|
||||
$this->instances = portfolio_instances();
|
||||
$cache = cache::make('core', 'portfolio_add_button_portfolio_instances');
|
||||
$instances = $cache->get('instances');
|
||||
if ($instances === false) {
|
||||
$instances = portfolio_instances();
|
||||
$cache->set('instances', $instances);
|
||||
}
|
||||
|
||||
$this->instances = $instances;
|
||||
if (empty($options)) {
|
||||
return true;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user