/** * Returns a cacheKey for the specified Template * * @param Template $template The template to generate the cacheKey for * @param array $globals An array of globals set on this template * * @return string The cache key */ public function getTemplateCacheKey(Template $template, $globals) { $locals = $template->getLocals(); $cachekey = ''; if ($template->isTopTemplate()) { $cachekey .= $this->Request->getAdjustedRequestURI(); } else { $cachekey .= $template->getContentType() . $template->getName(); } $cacheParams = array(); // any locals that aren't globals foreach ($locals as $name => $value) { if (!is_array($value) && !array_key_exists($name, $globals) && !preg_match("/^[A-Z\\-\\_0-9]+\$/", $name) && !preg_match("/\\-\\d+\$/", $name)) { $cacheParams[$name] = $value; } } if (isset($cacheParams['UseQueryStringInCacheKey']) && StringUtils::strToBool($cacheParams['UseQueryStringInCacheKey']) == true) { foreach ($_GET as $name => $value) { if (!is_array($value)) { $cacheParams['q_' . $name] = $value; } } } $cachekey .= '?'; if (!empty($cacheParams)) { ksort($cacheParams); foreach ($cacheParams as $n => $v) { $cachekey .= $n . '=' . substr($v, 0, 255) . '&'; } } $cachekey = rtrim($cachekey, '&'); $this->Logger->debug('Cache Key [' . $cachekey . ']'); return $cachekey; }