本文整理匯總了PHP中cache::cache_start方法的典型用法代碼示例。如果您正苦於以下問題:PHP cache::cache_start方法的具體用法?PHP cache::cache_start怎麽用?PHP cache::cache_start使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類cache
的用法示例。
在下文中一共展示了cache::cache_start方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: ceil
}
if ($_POST['summary'] == '') {
$_POST['summary'] = check::csubstr(trim(str_replace(" ", " ", str_replace("\r\n", "", strip_tags($_POST['intro'])))), 0, $arrGWeb['db_summary_len']);
}
if (is_array($_POST['photo'])) {
$_POST['thumbnail'] = $_POST['photo'][0]['photo'];
} else {
$_POST['thumbnail'] = $_POST['photo'];
}
$objWebInit->saveInfo($_POST, 0);
if ($arrGWeb['file_static']) {
//生成靜態頁麵
$intID = $objWebInit->getMaxID() - 1;
$strDir = ceil($intID / $arrGCache['cache_filenum']);
$objCache = new cache($arrGCache['cache_root'] . '-' . $strDir . '/' . $intID . $arrGWeb['file_suffix'], $arrGCache['cache_time']);
$objCache->cache_start();
$strContents = @file_get_contents('http://' . $_SERVER["HTTP_HOST"] . '/' . $arrGWeb['module_id'] . '/detail.php?id=' . $intID);
if ($strContents) {
echo $strContents;
}
$objCache->cache_end(false);
}
check::WindowLocation('index.php', 'page=' . $_GET['page']);
}
if (!is_array($arrMType) || empty($arrMType)) {
$arrMType = $objWebInit->getTypeList();
$arrMType = $objWebInit->formatTypeList(0, $arrMType);
}
$_SESSION['submitpasskey'] = md5(md5(time()));
//print_r($arrMType);
// 輸出到模板
示例2: updateCache
/**
* 更新頁麵緩存(純靜態和smarty緩存)
* @author 肖飛
* @param int $id 記錄ID數或者單頁數組的KEY
* @param int $type_id 欄目類型ID 便於清除列表頁的緩存
* @param array $arrMOutput 輸出到smartyd的數組
* @return void
*/
public function updateCache($id, $type_id = 1, $arrMOutput = array())
{
global $arrGWeb, $arrGCache;
if ($arrGWeb['file_static']) {
//生成靜態頁麵
$intID = intval($id);
$strDir = ceil($intID / $arrGCache['cache_filenum']);
if (empty($intID)) {
//單頁欄目
$intID = $id;
$strCacheFile = $arrGCache['cache_root'] . '/' . $id . $arrGWeb['file_suffix'];
@unlink($arrGCache['cache_root'] . '/' . $id . 'tw' . $arrGWeb['file_suffix']);
} else {
//其他欄目
$strCacheFile = $arrGCache['cache_root'] . '-' . $strDir . '/' . $intID . $arrGWeb['file_suffix'];
@unlink($arrGCache['cache_root'] . '-' . $strDir . '/' . $intID . 'tw' . $arrGWeb['file_suffix']);
}
$objCache = new cache($strCacheFile, $arrGCache['cache_time']);
$objCache->cache_start();
$strContents = @file_get_contents('http://' . $_SERVER["HTTP_HOST"] . $arrGWeb['WEB_ROOT_pre'] . '/' . $arrGWeb['module_id'] . '/detail.php?id=' . $intID);
if ($strContents) {
echo $strContents;
}
$objCache->cache_end(false);
}
if ($arrGWeb['URL_static']) {
//更新smarty緩存
$objSmarty = new SmartyTpl();
if (empty($arrMOutput['template_dir'])) {
$objSmarty->setTemplateDir($this->arrGSmarty['template_dir']);
} else {
$objSmarty->setTemplateDir($arrMOutput['template_dir']);
}
$objSmarty->setCompileDir($this->arrGSmarty['compile_dir']);
$objSmarty->setCacheDir($this->arrGSmarty['cache_dir']);
$objSmarty->plugins_dir = $this->arrGSmarty['plugins_dir'];
$arrMOutput['smarty_debug'] = '';
$arrMOutput['smarty_debug'] ? $objSmarty->compile_check = true : '';
$arrMOutput['smarty_debug'] ? $objSmarty->debugging = true : '';
$objSmarty->caching = $this->arrGSmarty['caching'];
if ($objSmarty->caching) {
$objSmarty->cache_lifetime = isset($this->arrGSmarty['cache_lifetime']) ? $this->arrGSmarty['cache_lifetime'] : 3600;
$objSmarty->cache_modified_check = isset($this->arrGSmarty['cache_modified_check']) ? $this->arrGSmarty['cache_modified_check'] : false;
}
if (!empty($arrMOutput['smarty_assign'])) {
while (list($key, $value) = each($arrMOutput['smarty_assign'])) {
$objSmarty->assign($key, $value);
}
}
if ($_SESSION['langset'] == 'zh_tw') {
$objSmarty->autoload_filters = array('output' => array('langset'));
}
$objSmarty->clearCache($arrMOutput['template_file'], $_SESSION['langset'] . '/');
$objSmarty->clearCache($arrMOutput['template_file'], $_SESSION['langset'] . '/index.php');
$objSmarty->clearCache($arrMOutput['template_file'], $_SESSION['langset'] . '/' . $arrGWeb['module_id'] . '/');
$objSmarty->clearCache($arrMOutput['template_file'], $_SESSION['langset'] . '/' . $arrGWeb['module_id'] . '/index.php');
$objSmarty->clearCache($arrMOutput['template_file'], $_SESSION['langset'] . '/' . $arrGWeb['module_id'] . '/list/');
$objSmarty->clearCache($arrMOutput['template_file'], $_SESSION['langset'] . '/' . $arrGWeb['module_id'] . '/list.php');
$objSmarty->clearCache($arrMOutput['template_file'], $_SESSION['langset'] . '/' . $arrGWeb['module_id'] . '/list/type_id-' . $type_id . $arrGWeb['file_suffix']);
$objSmarty->clearCache($arrMOutput['template_file'], $_SESSION['langset'] . '/' . $arrGWeb['module_id'] . '/list.php/type_id-' . $type_id . $arrGWeb['file_suffix']);
$objSmarty->clearCache($arrMOutput['template_file'], $_SESSION['langset'] . '/' . $arrGWeb['module_id'] . '/list.php?type_id=' . $type_id);
}
if ($arrGWeb['PDO_CACHE']) {
if (!empty($this->arrGPdoDB['PDO_CACHE_ROOT'])) {
check::delTreeDirs($this->arrGPdoDB['PDO_CACHE_ROOT']);
}
}
}
示例3: ceil
$intID = $v['id'];
if (empty($intID)) {
continue;
}
include_once '../../' . $_GET['id'] . '/config/var.inc.php';
$intNum = ceil($intID / $arrGCache['cache_filenum']);
if ($_SESSION['langset'] == 'zh_tw') {
$arrGWeb['file_suffix'] = 'tw' . $arrGWeb['file_suffix'];
}
if ($_GET['id'] == 'archives') {
$strDir = $arrGCache['cache_root'] . '/' . $_GET['id'] . '/' . $v['type_title_english'] . $arrGWeb['file_suffix'];
} else {
$strDir = $arrGCache['cache_root'] . '/' . $_GET['id'] . '-' . $intNum . '/' . $intID . $arrGWeb['file_suffix'];
}
$objCache = new cache($strDir);
$objCache->cache_start(true);
if ($_GET['id'] == 'archives') {
$strContents = file_get_contents('http://' . $_SERVER['HTTP_HOST'] . '/' . $_GET['id'] . '/detail.php?name=' . $v['type_title_english']);
} else {
$strContents = file_get_contents('http://' . $_SERVER['HTTP_HOST'] . '/' . $_GET['id'] . '/detail.php?id=' . $intID);
}
if ($strContents) {
header("HTTP/1.1 200 OK");
echo $strContents;
}
$objCache->cache_end(false);
}
check::AlertExit("網站靜態頁麵已重新生成 !", -1);
}
}
}