< ?php require('./smarty/Smarty.class.php'); $smarty = new Smarty; Z) $smarty->caching = true; if(!$smarty->is_cached('index.tpl')) // No cache available, do variable assignments here. ) $contents = get_database_contents(); $smarty->assign($contents); } $smarty->display('index.tpl'); ) ?>
这个首先判断是否有这个缓存文件!没有直接链接数据库!有的话!执行DISPLAY。就是读取缓存。大家看到上面的2个例子!对缓存有很大的理解了吧!
最新评论