| 148 |
lars |
1 |
clearCache()
|
|
|
2 |
|
|
|
3 |
clears the cache for a specific template
|
|
|
4 |
|
|
|
5 |
Description
|
|
|
6 |
===========
|
|
|
7 |
|
|
|
8 |
void
|
|
|
9 |
|
|
|
10 |
clearCache
|
|
|
11 |
|
|
|
12 |
string
|
|
|
13 |
|
|
|
14 |
template
|
|
|
15 |
|
|
|
16 |
string
|
|
|
17 |
|
|
|
18 |
cache\_id
|
|
|
19 |
|
|
|
20 |
string
|
|
|
21 |
|
|
|
22 |
compile\_id
|
|
|
23 |
|
|
|
24 |
int
|
|
|
25 |
|
|
|
26 |
expire\_time
|
|
|
27 |
|
|
|
28 |
- If you have [multiple caches](#caching.multiple.caches) for a
|
|
|
29 |
template, you can clear a specific cache by supplying the `cache_id`
|
|
|
30 |
as the second parameter.
|
|
|
31 |
|
|
|
32 |
- You can also pass a [`$compile_id`](#variable.compile.id) as a third
|
|
|
33 |
parameter. You can [group templates together](#caching.groups) so
|
|
|
34 |
they can be removed as a group, see the [caching section](#caching)
|
|
|
35 |
for more information.
|
|
|
36 |
|
|
|
37 |
- As an optional fourth parameter, you can supply a minimum age in
|
|
|
38 |
seconds the cache file must be before it will get cleared.
|
|
|
39 |
|
|
|
40 |
> **Note**
|
|
|
41 |
>
|
|
|
42 |
> Since Smarty version 3.1.14 it is possible to delete cache files
|
|
|
43 |
> by their individual expiration time at creation by passing
|
|
|
44 |
> constant SMARTY::CLEAR\_EXPIRED as fourth parameter.
|
|
|
45 |
|
|
|
46 |
<!-- -->
|
|
|
47 |
|
|
|
48 |
|
|
|
49 |
<?php
|
|
|
50 |
// clear the cache for a template
|
|
|
51 |
$smarty->clearCache('index.tpl');
|
|
|
52 |
|
|
|
53 |
// clear the cache for a particular cache id in an multiple-cache template
|
|
|
54 |
$smarty->clearCache('index.tpl', 'MY_CACHE_ID');
|
|
|
55 |
?>
|
|
|
56 |
|
|
|
57 |
|
|
|
58 |
|
|
|
59 |
See also [`clearAllCache()`](#api.clear.all.cache) and
|
|
|
60 |
[`caching`](#caching) section.
|