29 protected abstract function fetch(
$id, $name, $cache_id, $compile_id, &$content, &$mtime);
59 protected abstract function save(
$id, $name, $cache_id, $compile_id, $exp_time, $content);
70 protected abstract function delete($name, $cache_id, $compile_id, $exp_time);
81 $_cache_id = isset($cached->cache_id) ? preg_replace(
'![^\w\|]+!',
'_', $cached->cache_id) : null;
82 $_compile_id = isset($cached->compile_id) ? preg_replace(
'![^\w\|]+!',
'_', $cached->compile_id) : null;
84 $cached->filepath = sha1($cached->source->filepath . $_cache_id . $_compile_id);
96 $mtime = $this->
fetchTimestamp($cached->filepath, $cached->source->name, $cached->cache_id, $cached->compile_id);
97 if ($mtime !== null) {
98 $cached->timestamp = $mtime;
99 $cached->exists = !!$cached->timestamp;
103 $this->
fetch($cached->filepath, $cached->source->name, $cached->cache_id, $cached->compile_id, $cached->content, $timestamp);
104 $cached->timestamp = isset($timestamp) ? $timestamp :
false;
105 $cached->exists = !!$cached->timestamp;
118 $cached = $_template->cached;
120 $content = $cached->content ? $cached->content : null;
121 $timestamp = $cached->timestamp ? $cached->timestamp : null;
122 if ($content === null || !$timestamp) {
124 $_template->cached->filepath,
125 $_template->source->name,
126 $_template->cache_id,
127 $_template->compile_id,
132 if (isset($content)) {
133 $_smarty_tpl = $_template;
134 eval(
"?>" . $content);
150 $_template->cached->filepath,
151 $_template->source->name,
152 $_template->cache_id,
153 $_template->compile_id,
154 $_template->properties[
'cache_lifetime'],
168 $this->cache = array();
169 return $this->
delete(null, null, null, $exp_time);
182 public function clear(
Smarty $smarty, $resource_name, $cache_id, $compile_id, $exp_time)
184 $this->cache = array();
185 return $this->
delete($resource_name, $cache_id, $compile_id, $exp_time);
197 $id = $cached->filepath;
198 $name = $cached->source->name .
'.lock';
201 if ($mtime === null) {
202 $this->
fetch(
$id, $name, null, null, $content, $mtime);
205 return $mtime && time() - $mtime < $smarty->locking_timeout;
216 $cached->is_locked =
true;
218 $id = $cached->filepath;
219 $name = $cached->source->name .
'.lock';
220 $this->
save(
$id, $name, null, null, $smarty->locking_timeout,
'');
231 $cached->is_locked =
false;
233 $name = $cached->source->name .
'.lock';
234 $this->
delete($name, null, null, null);
clearAll(Smarty $smarty, $exp_time=null)
Empty cache.
fetch($id, $name, $cache_id, $compile_id, &$content, &$mtime)
fetch cached content and its modification time from data source
releaseLock(Smarty $smarty, Smarty_Template_Cached $cached)
Unlock cache for this template.
acquireLock(Smarty $smarty, Smarty_Template_Cached $cached)
Lock cache for this template.
hasLock(Smarty $smarty, Smarty_Template_Cached $cached)
Check is cache is locked for this template.
Smarty plugin to format text blocks.
process(Smarty_Internal_Template $_template, Smarty_Template_Cached $cached=null)
Read the cached template and process the header.
populate(Smarty_Template_Cached $cached, Smarty_Internal_Template $_template)
populate Cached Object with meta data from Resource
clear(Smarty $smarty, $resource_name, $cache_id, $compile_id, $exp_time)
Empty cache for a specific template.
populateTimestamp(Smarty_Template_Cached $cached)
populate Cached Object with timestamp and exists from Resource
fetchTimestamp($id, $name, $cache_id, $compile_id)
Fetch cached content's modification timestamp from data source.
save($id, $name, $cache_id, $compile_id, $exp_time, $content)
Save content to cache.
writeCachedContent(Smarty_Internal_Template $_template, $content)
Write the rendered template output to cache.