一个smary的简单问题哦

$smarty = new Smarty;

$smarty->force_compile = true;
$smarty->debugging = true;
$smarty->caching = true;
$smarty->cache_lifetime = 120;
if(!$smarty->isCached('index.tpl')){
echo 'no cache';

} else {
echo 'cache';
}
$smarty->display('index.tpl');

请教一下,为什么我这样设置每次都是 no cache.
在我的cache目录下己经生成了缓存文件。

参考isCached() — 检查模板是否已经缓存

此函数仅在 $caching设置为Smarty::CACHING_LIFETIME_CURRENT或Smarty::CACHING_LIFETIME_SAVED的时候启用。 参见 缓存。

<?php
$smarty->setCaching(Smarty::CACHING_LIFETIME_CURRENT);

if(!$smarty->isCached('index.tpl')) {
// do database calls, assign vars here
}

$smarty->display('index.tpl');
?>

参考Smarty的配置与高级缓存技术

注意:如果你发现缓存文件每次浏览都会发生改变,请看 Smarty的 force_compile , 它会强迫Smarty每次调用(重新)编译模板。这项设置不受$compile_check的限制。默认情况下,它是无效的。它对于开发和调试很方便.但它决不能使用于产品环境下.如果启动了缓存,每次将会重新生成缓存文件.