update of cache resources for template function calls in nocache mode

This commit is contained in:
Uwe Tews
2014-11-09 10:20:06 +01:00
parent 223cdc0787
commit adc6091c4d
4 changed files with 81 additions and 0 deletions

View File

@@ -449,4 +449,19 @@ class Smarty_Template_Cached
return false;
}
/**
* Read cache content from handler
*
* @param Smarty_Internal_Template $_template template object
*
* @return string content
*/
public function read(Smarty_Internal_Template $_template)
{
if (!$_template->source->recompiled) {
return $this->handler->readCachedContent($_template);
}
return false;
}
}

View File

@@ -169,6 +169,34 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource
);
}
/**
* Read cached template from cache
*
* @param Smarty_Internal_Template $_template template object
*
* @return string content
*/
public function readCachedContent(Smarty_Internal_Template $_template)
{
$content = $_template->cached->content ? $_template->cached->content : null;
$timestamp = null;
if ($content === null) {
$timestamp = null;
$this->fetch(
$_template->cached->filepath,
$_template->source->name,
$_template->cache_id,
$_template->compile_id,
$content,
$timestamp
);
}
if (isset($content)) {
return $content;
}
return false;
}
/**
* Empty cache
*

View File

@@ -126,6 +126,29 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource
return $this->write(array($_template->cached->filepath => $content), $_template->properties['cache_lifetime']);
}
/**
* Read cached template from cache
*
* @param Smarty_Internal_Template $_template template object
*
* @return string content
*/
public function readCachedContent(Smarty_Internal_Template $_template)
{
$content = $_template->cached->content ? $_template->cached->content : null;
$timestamp = null;
if ($content === null) {
if (!$this->fetch($_template->cached->filepath, $_template->source->name, $_template->cache_id, $_template->compile_id, $content, $timestamp, $_template->source->uid)) {
return false;
}
}
if (isset($content)) {
return $content;
}
return false;
}
/**
* Empty cache
* {@internal the $exp_time argument is ignored altogether }}

View File

@@ -117,6 +117,21 @@ class Smarty_Internal_CacheResource_File extends Smarty_CacheResource
return false;
}
/**
* Read cached template from cache
*
* @param Smarty_Internal_Template $_template template object
*
* @return string content
*/
public function readCachedContent(Smarty_Internal_Template $_template)
{
if (is_file($_template->cached->filepath)) {
return file_get_contents($_template->cached->filepath);
}
return false;
}
/**
* Empty cache
*