smarty与php缓存的操作

来源:互联网 发布:淘宝卖家代销流程图 编辑:程序博客网 时间:2024/05/16 15:43

1)使用缓存

要开启smarty的缓存,只需将caching设为true,并指定cache_dir即可。使用cache_lefetime指定缓存生存时间,单位为秒

2)清楚缓存

Clear_all_cache();//清除所有缓存

Clear_cache(“index.tpl”);//清除index.tpl的缓存

Clear_cacache(“index.tpl”,cache_id);//清除指定id的缓存

3)使用自定义缓存方式

$smarty->cache_handler_func使用自定的函数处理缓存

$smarty->cache_hander_func=”myCache”;

FunctionmyCache($action,&$smarty_obj,&$cache_content,$tpl_file=null,$cache_id=null,$complie_id=null){

Switch($action){

Case “read”;//读取缓存内容

Case “write”;//写入缓存内容

Case “clear”;

}

原创粉丝点击