public function render($name, array $values = array()) { if (defined('ENV_DEV')) { //$this->engine->clearCacheFiles(); //$this->engine->clearTemplateCache(); $this->engine->clearAllCache(); $this->engine->clearCompiledTemplate(); } $template = $this->engine->createTemplate($name . $this->suffix); $template->assign($values); return $template->fetch(); }
/** * Expires the cache * * @param boolean $expireAll expire the whole cache */ public function CacheExpire($expireAll = false) { if ($expireAll) { $this->tpl->clearAllCache(); return; } if (!$this->project) { return; } $epoch = $this->GetProject()->GetEpoch(); if (empty($epoch)) { return; } $age = $this->GetProject()->GetAge(); $this->tpl->clearCache(null, $this->GetCacheKeyPrefix(), null, $age); $this->tpl->clearCache('projectlist.tpl', $this->GetCacheKeyPrefix(false), null, $age); }
/** * Handle the lazy template cache invalidation * * @param string $template template name * @param string $cache_id cache id * @param string $compile_id compile id */ public function check_template_invalidation($template, $cache_id, $compile_id) { static $last_flush = null; if (!file_exists($this->getCacheDir() . 'last_template_flush')) { @touch($this->getCacheDir() . 'last_template_flush', time()); } elseif (defined('_DB_PREFIX_')) { if ($last_flush === null) { $sql = 'SELECT UNIX_TIMESTAMP(last_flush) as last_flush FROM `' . _DB_PREFIX_ . 'smarty_last_flush` WHERE type=\'template\''; $last_flush = Db::getInstance()->getValue($sql, false); } if ((int) $last_flush && @filemtime($this->getCacheDir() . 'last_template_flush') < $last_flush) { @touch($this->getCacheDir() . 'last_template_flush', time()); parent::clearAllCache(); } else { if ($cache_id !== null && (is_object($cache_id) || is_array($cache_id))) { $cache_id = null; } if ($this->is_in_lazy_cache($template, $cache_id, $compile_id) === false) { // insert in cache before the effective cache creation to avoid nasty race condition $this->insert_in_lazy_cache($template, $cache_id, $compile_id); parent::clearCache($template, $cache_id, $compile_id); } } } }
global $config; $config_tmp = $db->fetchAll($get_sysconf); foreach ($config_tmp as $tmp) { $config[$tmp['key']] = $tmp['value']; } //初始化smarty对象 global $smarty; $smarty = new Smarty(); $smarty->setCompileDir(ROOT_PATH . 'data/compiles'); $smarty->setTemplateDir(ROOT_PATH . 'themes/' . $config['themes']); $smarty->setCacheDir(ROOT_PATH . 'data/caches'); $smarty->setCacheLifetime(2); //设置缓存文件超时时间为1800秒 //Debug模式下每次都强制编译输出 if ($debug_mode) { $smarty->clearAllCache(); $smarty->clearCompiledTemplate(); $smarty->force_compile = true; } //设置系统设置 assign('config', $config); //设置语言包 assign('LANG', $lang); //设置网站参数 assign('config', $config); //设置模板路径 assign('template_dir', 'themes/' . $config['themes'] . '/'); //读取ukey参数,记录推荐人信息 $ukey = getGET('ukey'); if ($ukey != '') { $ukey = intval($ukey);
public function clearAllCache($exp_time = null, $type = null) { return $this->smarty->clearAllCache($exp_time, $type); }
/** * Clear cache for Smarty * * @param Smarty $smarty */ public static function clearCache($smarty, $tpl = false, $cache_id = null, $compile_id = null) { return $smarty->clearAllCache(); }
public function clearAllCache() { $this->smarty->clearAllCache(); }