smarty中的缓存

先复制官方的一段文章:翻译了一下

$cache_lifetime

This is the length of time in seconds that a template cache is valid. Once this time has expired, the cache will be regenerated.

 

  • $caching must be turned on (either 1 or 2) for $cache_lifetime to have any purpose.

  • A value of -1 will force the cache to never expire.

  • A value of 0 will cause the cache to always regenerate (good for testing only, to disable caching a more efficient method is to set $caching = 0).

  • If you want to give certain templates their own cache lifetime, you could do this by setting $caching = 2, then set $cache_lifetime to a unique value just before calling display() or fetch().

If $force_compile is enabled, the cache files will be regenerated every time, effectively disabling caching. You can clear all the cache files with the clear_all_cache() function, or individual cache files (or groups) with the clear_cache() function.

 

翻译:

 

     缓存生存期,以秒为单位,在这个时间段内,模板缓存有效。一旦这个时间过期,这个缓存就将重新生成

     1。$caching 必须打开(要么设置1或者2),否则对于$cache_liftetime没有任何作用

     2。当$caching=-1时,缓存将永不过期

     3。当$caching=0时,不缓存(用于测试,当不需要缓存时,设置$caching=0,这是一个有效的方法)

     4。如果你想某个特定的模板有特定的缓存生存期,你可以通过设置$caching=2来实现,然后可以在调用display()或者fetch()函数之前,设置$cache_liftetime特定的值

 

如果$force_compile打开了,缓存文件将每次重新生成,这个也是有效的防止缓存的方法。你可以利用clear_all_cache()这个函数清除所有的缓存文件,或者可以利用clear_cache()这个函数清除特定的文件

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值