本文整理匯總了PHP中factory::saveCache方法的典型用法代碼示例。如果您正苦於以下問題:PHP factory::saveCache方法的具體用法?PHP factory::saveCache怎麽用?PHP factory::saveCache使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類factory
的用法示例。
在下文中一共展示了factory::saveCache方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: main
/**
* Website main
*/
public static function main() {
define('NYROVERSION', '0.2');
$globalContent = null;
$globalVars = null;
$cacheInst = null;
$cacheInstVars = null;
try {
self::init();
$resp = response::getInstance();
self::$cfg->overload(__CLASS__.'Response');
if (self::$cfg->globalCache && !request::isPost() && count($_GET) == 0 && $resp->canGlobalCache()) {
$prm = is_array(self::$cfg->globalCache) ? self::$cfg->globalCache : array();
$cacheInst = cache::getInstance(array_merge(array('serialize'=>false), $prm));
$id = str_replace('/', '._.', '/'.request::get('request')).(request::isAjax() ? '-ajax' : '');
$cacheInst->get($globalContent, array(
'id'=>$id
));
$cacheInstVars = cache::getInstance(array_merge(array('serialize'=>true), $prm));
$cacheInstVars->get($globalVars, array(
'id'=>$id.'-vars'
));
}
if (is_null($globalContent)) {
request::execModule();
if (DEV) {
debug::timer('nyroProcess');
debug::timer('nyroRender');
}
$resp->setContent(request::publishModule());
}
} catch (module_exception $e) {
session::setFlash('nyroError', 'MODULE or ACTION NOT FOUND<br />'.self::handleError($e));
$resp->error(null, 404);
} catch (nException $e) {
session::setFlash('nyroError', self::handleError($e));
$resp->error(null, 500);
} catch (PDOException $e) {
session::setFlash('nyroError', self::handleError($e));
$resp->error(null, 500);
} catch (Exception $e) {
session::setFlash('nyroError', self::handleError($e));
$resp->error(null, 500);
}
try {
factory::saveCache();
if ($cacheInst) {
if ($globalContent) {
$resp->setVarsFromGlobalCache($globalVars);
echo $globalContent;
} else {
$globalVars = $resp->getVarsForGlobalCache();
$globalContent = $resp->send();
$cacheInst->save();
$cacheInstVars->save();
echo $globalContent;
}
} else {
echo $resp->send();
}
} catch (Exception $e) {
echo debug::trace($e);
}
}