Skip to content

Commit

Permalink
Enable cache for categories menu in course catalogue - refs #2822
Browse files Browse the repository at this point in the history
  • Loading branch information
aragonc committed Mar 1, 2019
1 parent c828bec commit 120a8d7
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion main/auth/courses_categories.php
Expand Up @@ -101,14 +101,29 @@
</div>
<div class="col-md-<?php echo $showSessions ? '4' : '6'; ?>">
<?php
$categoriesSelect = '';
$cacheAvailable = api_get_configuration_value('apc');
$accessUrlId = api_get_current_access_url_id();
if ($cacheAvailable === true) {
$apcVar = api_get_configuration_value('apc_prefix').'_'.$accessUrlId.'_course_categories_select';
if (apcu_exists($apcVar)) {
$categoriesSelect = apcu_fetch($apcVar);
} else {
$categoriesSelect = getOptionSelect($list_categories, $codeType);
apcu_store($apcVar, $categoriesSelect, 60);
}
} else {
$categoriesSelect = getOptionSelect($list_categories, $codeType);
}

$webAction = api_get_path(WEB_CODE_PATH).'auth/courses.php';
$form = '<form action="'.$webAction.'" method="GET">';
$form .= '<input type="hidden" name="action" value="'.$action.'">';
$form .= '<input type="hidden" name="pageCurrent" value="'.$pageCurrent.'">';
$form .= '<input type="hidden" name="pageLength" value="'.$pageLength.'">';
$form .= '<div class="form-group">';
$form .= '<label>'.get_lang('CourseCategories').'</label>';
$form .= getOptionSelect($list_categories, $codeType);
$form .= $categoriesSelect;
$form .= '</div>';
$form .= '</form>';
echo $form;
Expand Down

1 comment on commit 120a8d7

@jmontoyaa
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No usar directamente "apcu_store" directamente usar la capa de doctrine cache:

$cacheDriver = new \Doctrine\Common\Cache\ApcuCache();
if ($cacheDriver->contains($key)) {
return $cacheDriver->fetch($key);
}

Please sign in to comment.