首页  >  文章  >  后端开发  >  smarty 在设定关了cache 能不能在指定的文件用cache?该如何解决

smarty 在设定关了cache 能不能在指定的文件用cache?该如何解决

WBOY
WBOY原创
2016-06-13 12:11:11831浏览

smarty 在设定关了cache 能不能在指定的文件用cache?
做了个小function, online_count(), 显示在线人数, 中间技术不说,因为这是一个小项目上用的,准确度要求不高,但是必须要显示

$smarty -> assign("online_count",online_count());

我不想每次都去查问这个统计在线人数的function online_count();

在config 中已设定了
我的config.php

<br />$smarty = new Smarty();<br />//.......跳过<br />$smarty -> caching = 0; <br />//在线人数<br />$smarty -> assign("online_count",online_count());<br />


请问还有可能把online_count这变量设定为cache吗?
为什么要把这个放到config.php赋值? 
因为我在线人数显示在header  而header没有PHP,只有模版,也没有任何PHP  $smarty -> display()  这个header.html模板
都是在其他模板引入的            {include file="common/header.html"}

请问还有什么方法?

先不理这在线人数要cache起来的要求是否无理,在技术的层面能有什么方法解决吗?
------解决思路----------------------
可以在online_count這個function中做cache。

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn