Heim  >  Artikel  >  Backend-Entwicklung  >  smarty 在设定关了cache 能不能在指定的文件用cache?该如何解决

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

WBOY
WBOYOriginal
2016-06-13 12:11:11831Durchsuche

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。

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn