二、Smarty缓存的使用与清除
三、Smarty的局部缓存 第一个: insert_函数默认是不缓存,这个属性是不能修改 使用方法:例子 index.php中,
index.html中,
第二个: smarty_block 定义一个block:smarty_block_name($params,$content, &$smarty){return $content;} //name表示区域名 注册block:$smarty->register_block('name', 'smarty_block_name', false); //第三参数false表示该区域不被缓存 模板写法:{name}内容{/name} 写成block插件: 1)定义一件插件函数:block.cacheless.php,放在smarty的plugins目录 block.cacheless.php的内容如下:
2) 编写程序及模板 示例程序:testCacheLess.php
所用的模板:cache.tpl
已经缓存的:{$smarty.now}
该函数的一般是根椐$action来判断缓存当前操作:
一般使用md5($tpl_file.$cache_id.$compile_id)作为唯一的cache_id 如果需要,可使用gzcompress和gzuncompress来压缩和解压。 |
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号