jquery教程

推荐列表 站点导航

当前位置:首页 > jquery > jquery教程 >

有关smarty缓存的应用

来源:网络整理  作者:  发布时间:2020-12-26 18:44
一、Smarty缓存的配置:$smarty-gt;cache-dir=quot;目录名quot;; //创建缓存目录名 $smarty-gt;caching=true; //开启缓存,为false的时候...

$cache_id=null, $tpl_file=null。

$compile_id=null){ } 该函数的一般是根椐$action来判断缓存当前操作: 复制代码 代码示例: switch($action){ case read://读取缓存内容 case write://写入缓存 case clear://清空 } 一般使用md5($tpl_file.$cache_id.$compile_id)作为唯一的cache_id 如果需要。

$smarty) { return $content; } ? 2) 编写程序及模板 示例程序:testCacheLess.php 复制代码 代码如下: ?php include('Smarty.class.php'); $smarty = new Smarty; $smarty-caching=true; $smarty-cache_lifetime = 6; $smarty-display('cache.tpl'); ? 所用的模板:cache.tpl 已经缓存的:{$smarty.now}br {cacheless} 没有缓存的:{$smarty.now} {/cacheless} 四、自定义缓存 设置cache_handler_func使用自定义的函数处理缓存 如: 复制代码 代码示例: $smarty-cache_handler_func = myCache; function myCache($action, 复制代码 代码如下: {insert name=get_time} 第二个: smarty_block 定义一个block:smarty_block_name($params,为false的时候缓存无效 $smarty-cache_lifetime=60; //缓存时间,单位是秒 二、Smarty缓存的使用与清除 复制代码 代码如下: $marty-display(cache.tpl,cache_id); //清楚index.php中指定ID的缓存 三、Smarty的局部缓存 第一个: insert_函数默认是不缓存, false); //第三参数false表示该区域不被缓存 模板写法:{name}内容{/name} 写成block插件: 1)定义一件插件函数:block.cacheless.php, 一、Smarty缓存的配置: 复制代码 代码如下: $smarty-cache-dir=目录名; //创建缓存目录名 $smarty-caching=true; //开启缓存, 复制代码 代码如下: function insert_get_time(){ return date(Y-m-d H:m:s); } index.html中,可使用gzcompress和gzuncompress来压缩和解压,放在smarty的plugins目录 block.cacheless.php的内容如下: 复制代码 代码如下: ?php function smarty_block_cacheless($param, $content, $smarty_obj, , 'smarty_block_name',$content,这个属性是不能修改 使用方法:例子 index.php中。

$cache_content。

$smarty){return $content;} //name表示区域名 注册block:$smarty-register_block('name',cache_id); //创建带ID的缓存 $marty-clear_all_cache(); //清楚所有缓存 $marty-clear_cache(index.php); //清楚index.php中的缓存 $marty-clear_cache(index.php',。

相关热词:

本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供用于网络技术学习参考,学习中请遵循相关法律法规!

本文地址: https://v30.fanwenzhu.com/jq/jc/9502.shtml

相关文章
最新文章
PHP识别相片是否是颠倒的 PHP识别相片是否是颠倒的

时间:2020-12-28

python编程有哪些ide python编程有哪些ide

时间:2020-12-28

python开发工程师是做什么 python开发工程师是做什么

时间:2020-12-28

php构造函数的作用 php构造函数的作用

时间:2020-12-28

php怎么跟数据库连接 php怎么跟数据库连接

时间:2020-12-28

php实现顺序线性表 php实现顺序线性表

时间:2020-12-28

Python多重继承中的菱形继 Python多重继承中的菱形继

时间:2020-12-28

php中break的作用 php中break的作用

时间:2020-12-28

Copyright © www.juheyunku.com      关于 | 合作 | 声明 | 联系 | 更新 | 地图 | Tags

有关smarty缓存的应用

2020-12-26 编辑:

$cache_id=null, $tpl_file=null。

$compile_id=null){ } 该函数的一般是根椐$action来判断缓存当前操作: 复制代码 代码示例: switch($action){ case read://读取缓存内容 case write://写入缓存 case clear://清空 } 一般使用md5($tpl_file.$cache_id.$compile_id)作为唯一的cache_id 如果需要。

$smarty) { return $content; } ? 2) 编写程序及模板 示例程序:testCacheLess.php 复制代码 代码如下: ?php include('Smarty.class.php'); $smarty = new Smarty; $smarty-caching=true; $smarty-cache_lifetime = 6; $smarty-display('cache.tpl'); ? 所用的模板:cache.tpl 已经缓存的:{$smarty.now}br {cacheless} 没有缓存的:{$smarty.now} {/cacheless} 四、自定义缓存 设置cache_handler_func使用自定义的函数处理缓存 如: 复制代码 代码示例: $smarty-cache_handler_func = myCache; function myCache($action, 复制代码 代码如下: {insert name=get_time} 第二个: smarty_block 定义一个block:smarty_block_name($params,为false的时候缓存无效 $smarty-cache_lifetime=60; //缓存时间,单位是秒 二、Smarty缓存的使用与清除 复制代码 代码如下: $marty-display(cache.tpl,cache_id); //清楚index.php中指定ID的缓存 三、Smarty的局部缓存 第一个: insert_函数默认是不缓存, false); //第三参数false表示该区域不被缓存 模板写法:{name}内容{/name} 写成block插件: 1)定义一件插件函数:block.cacheless.php, 一、Smarty缓存的配置: 复制代码 代码如下: $smarty-cache-dir=目录名; //创建缓存目录名 $smarty-caching=true; //开启缓存, 复制代码 代码如下: function insert_get_time(){ return date(Y-m-d H:m:s); } index.html中,可使用gzcompress和gzuncompress来压缩和解压,放在smarty的plugins目录 block.cacheless.php的内容如下: 复制代码 代码如下: ?php function smarty_block_cacheless($param, $content, $smarty_obj, , 'smarty_block_name',$content,这个属性是不能修改 使用方法:例子 index.php中。

$cache_content。

$smarty){return $content;} //name表示区域名 注册block:$smarty-register_block('name',cache_id); //创建带ID的缓存 $marty-clear_all_cache(); //清楚所有缓存 $marty-clear_cache(index.php); //清楚index.php中的缓存 $marty-clear_cache(index.php',。

本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供学习参考!
本文地址为 https://v30.fanwenzhu.com/jq/jc/9502.shtml

相关文章

风云图片

推荐阅读

返回jquery教程频道首页