30 abstract protected function fetch($id, $name, $cache_id, $compile_id, &$content, &$mtime);
61 abstract protected function save($id, $name, $cache_id, $compile_id, $exp_time, $content);
73 abstract protected function delete($name, $cache_id, $compile_id, $exp_time);
85 $_cache_id = isset($cached->cache_id) ? preg_replace(
'![^\w\|]+!',
'_', $cached->cache_id) : null;
86 $_compile_id = isset($cached->compile_id) ? preg_replace(
'![^\w\|]+!',
'_', $cached->compile_id) : null;
87 $path = $cached->source->filepath . $_cache_id . $_compile_id;
88 $cached->filepath = sha1($path);
89 if ($_template->smarty->cache_locking) {
90 $cached->lock_id = sha1(
'lock.' . $path);
104 $mtime = $this->
fetchTimestamp($cached->filepath, $cached->source->name, $cached->cache_id, $cached->compile_id);
105 if ($mtime !== null) {
106 $cached->timestamp = $mtime;
107 $cached->exists = !!$cached->timestamp;
112 $this->
fetch($cached->filepath, $cached->source->name, $cached->cache_id, $cached->compile_id, $cached->content, $timestamp);
113 $cached->timestamp = isset($timestamp) ? $timestamp :
false;
114 $cached->exists = !!$cached->timestamp;
128 $cached = $_template->cached;
130 $content = $cached->content ? $cached->content : null;
131 $timestamp = $cached->timestamp ? $cached->timestamp : null;
132 if ($content === null || !$timestamp) {
134 $_template->cached->filepath,
135 $_template->source->name,
136 $_template->cache_id,
137 $_template->compile_id,
142 if (isset($content)) {
146 $_smarty_tpl = $_template;
147 eval(
"?>" . $content);
166 $_template->cached->filepath,
167 $_template->source->name,
168 $_template->cache_id,
169 $_template->compile_id,
170 $_template->properties[
'cache_lifetime'],
184 $content = $_template->cached->content ? $_template->cached->content : null;
186 if ($content === null) {
189 $_template->cached->filepath,
190 $_template->source->name,
191 $_template->cache_id,
192 $_template->compile_id,
197 if (isset($content)) {
213 $this->cache = array();
215 return $this->
delete(null, null, null, $exp_time);
229 public function clear(
Smarty $smarty, $resource_name, $cache_id, $compile_id, $exp_time)
231 $this->cache = array();
234 if (isset($resource_name)) {
235 $_save_stat = $smarty->caching;
236 $smarty->caching =
true;
237 $tpl =
new $smarty->template_class($resource_name, $smarty);
238 $smarty->caching = $_save_stat;
240 if ($tpl->source->exists) {
241 $cache_name = $tpl->source->name;
246 if ($smarty->allow_ambiguous_resources) {
247 $_templateId = $tpl->source->unique_resource . $tpl->cache_id . $tpl->compile_id;
249 $_templateId = $smarty->joined_template_dir .
'#' . $resource_name . $tpl->cache_id . $tpl->compile_id;
251 if (isset($_templateId[150])) {
252 $_templateId = sha1($_templateId);
254 unset($smarty->template_objects[$_templateId]);
259 return $this->
delete($cache_name, $cache_id, $compile_id, $exp_time);
272 $id = $cached->lock_id;
273 $name = $cached->source->name .
'.lock';
275 $mtime = $this->
fetchTimestamp($id, $name, $cached->cache_id, $cached->compile_id);
276 if ($mtime === null) {
277 $this->
fetch($id, $name, $cached->cache_id, $cached->compile_id, $content, $mtime);
279 return $mtime && ($t = time()) - $mtime < $smarty->locking_timeout;
292 $cached->is_locked =
true;
293 $id = $cached->lock_id;
294 $name = $cached->source->name .
'.lock';
295 $this->
save($id, $name, $cached->cache_id, $cached->compile_id, $smarty->locking_timeout,
'');
308 $cached->is_locked =
false;
309 $name = $cached->source->name .
'.lock';
310 $this->
delete($name, $cached->cache_id, $cached->compile_id, null);