smarty缓存:Smarty的缓存Cache操作窍门技巧来源: 发布时间:星期一, 2009年1月12日 浏览:12次 评论:0
![]() 要开启smarty ![]() 使用cache_lefetime指定缓存Cache生存时间,单位为秒 要对相同页面生成多个区别 ![]() ![]() ![]() 2、清除缓存Cache clear_all_cache ![]() clear_cache('index.tpl');//清除index.tpl ![]() clear_cache('index.tpl',cache_id);//清除指定id ![]() 3、使用自定义缓存Cache方式 设置cache_handler_func使用自定义 ![]() ![]() 如: $smarty->cache_handler_func = "myCache"; function myCache($action, &$smarty_obj, &$cache_content, $tpl_file=null, $cache_id=null, $compile_id=null){ } 该 ![]() ![]() ![]() switch($action){ ![]() ![]() ![]() 如果需要,可使用gzcompress和gzuncompress来压缩和解压 4、局部关闭缓存Cache 要在某些区域使缓存Cache失效(只对需要 ![]() inser: 定义 ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 参数通过$params传入 也可以做成insert插件,文件名命名为:insert.xx.php, ![]() register_block: 定义 ![]() ![]() 注册block:$smarty->register_block('name', 'smarty_block_name', false); //第 3参数false表示该区域不被缓存Cache 模板写法:{name}内容{/name} 写成block插件: 1)定义 ![]() ![]() ![]() block.cacheless.php ![]() <?php 2) 编写 ![]() 举例 ![]() <?php 所用 ![]() 已经缓存Cache ![]() {cacheless} 没有缓存Cache ![]() {/cacheless} 0
相关文章读者评论发表评论 |
|