Introduction - cache
Cache FAQ
- 1. What exactly is this cache feature?
- 2. What about data?
- 3. Is the cached version regenerated when the template changes?
- 4. Is there any TTL setting?
- 5. Any way to flush the cache?
- 6. Does this give significant performance gains?
This is the way to bypass RegExp parsing on template load. Instead of parsing the original template on every request, we keep its internal representation (a serialized array, essentially) and load it instead.
Think about template compilation in Smarty. Only Sigma does not compile templates to PHP code.
No data caching is taking place. If you want to do this, consider using some of the PEAR's cache packages.
No. Cached version is considered valid until the source template changes.
Cache usage
Caching is completely transparent. To take advantage of this feature you only have to either pass a second parameter to the constructor or call a setCacheRoot() method later.
<?php require_once 'HTML/Template/Sigma.php'; $tpl =& new HTML_Template_Sigma('./templates', './templates/prepared'); $tpl->loadTemplateFile('default.html'); // go on ?> |
For each distinct template file in ./templates loaded with either loadTemplatefile(), addBlockfile(), replaceBlockfile() or <!-- INCLUDE --> a prepared version will be generated in ./templates/prepared.
Пред. | Начало | След. |
Introduction - template syntax | Уровень выше | constructor HTML_Template_Sigma() |