TracNav menu
-
Documentation
- Introduction
- Creating templates
-
Adding variables...
- Using the simpleCondition template
- Creating conditional templates
- Creating alternating rows?
-
Advanced features
- Reading templates from different data sources
- Variable Modifiers
- Improving performance with template caches
- Output Filters
- Input Filters
- Tag Reference
- FAQ
- Home
-
Extending patTemplate...
- Download
Using a template cache
When using a template cache, patTemplate does not have to apply regular expressions to your template source for every request, but cache the result of the reader.
Using a template cache is extremely easy:
$tmpl = new patTemplate();
$tmpl->setRoot('templates');
$tmpl->useTemplateCache('File', array(
'cacheFolder' => './tmplCache',
'lifetime' => 10,
'filemode' => 0644
)
);
$tmpl->readTemplatesFromInput('myTemplate.tmpl');
$tmpl->displayParsedTemplate();
The following caches are available:
- File
- MMCache
- eAccelerator
Each of these caches has different options, please refer to the API documentation of the cache to learn about the supported parameters.
How caches work
When enabling a cache, patTemplate will store a serialized array containing all templates, that have been read from a file in the cache. The next time you call readTemplatesFromInput(), patTemplate will first check, whether there is a cached version instead of reading the template from the file and evaluating all enclosed tags.
The template cache will not cache the output of your pages.
