首頁  >  文章  >  後端開發  >  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