本文整理汇总了PHP中ParserOutput::setCacheRevisionId方法的典型用法代码示例。如果您正苦于以下问题:PHP ParserOutput::setCacheRevisionId方法的具体用法?PHP ParserOutput::setCacheRevisionId怎么用?PHP ParserOutput::setCacheRevisionId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParserOutput
的用法示例。
在下文中一共展示了ParserOutput::setCacheRevisionId方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save
/**
* @param ParserOutput $parserOutput
* @param WikiPage $page
* @param ParserOptions $popts
* @param string $cacheTime Time when the cache was generated
* @param int $revId Revision ID that was parsed
*/
public function save($parserOutput, $page, $popts, $cacheTime = null, $revId = null)
{
$expire = $parserOutput->getCacheExpiry();
if ($expire > 0) {
$cacheTime = $cacheTime ?: wfTimestampNow();
if (!$revId) {
$revision = $page->getRevision();
$revId = $revision ? $revision->getId() : null;
}
$optionsKey = new CacheTime();
$optionsKey->mUsedOptions = $parserOutput->getUsedOptions();
$optionsKey->updateCacheExpiry($expire);
$optionsKey->setCacheTime($cacheTime);
$parserOutput->setCacheTime($cacheTime);
$optionsKey->setCacheRevisionId($revId);
$parserOutput->setCacheRevisionId($revId);
$parserOutputKey = $this->getParserOutputKey($page, $popts->optionsHash($optionsKey->mUsedOptions, $page->getTitle()));
// Save the timestamp so that we don't have to load the revision row on view
$parserOutput->setTimestamp($page->getTimestamp());
$msg = "Saved in parser cache with key {$parserOutputKey}" . " and timestamp {$cacheTime}" . " and revision id {$revId}" . "\n";
$parserOutput->mText .= "\n<!-- {$msg} -->\n";
wfDebug($msg);
// Save the parser output
$this->mMemc->set($parserOutputKey, $parserOutput, $expire);
// ...and its pointer
$this->mMemc->set($this->getOptionsKey($page), $optionsKey, $expire);
Hooks::run('ParserCacheSaveComplete', array($this, $parserOutput, $page->getTitle(), $popts, $revId));
} else {
wfDebug("Parser output was marked as uncacheable and has not been saved.\n");
}
}