本文整理汇总了PHP中FileRepo::getLocalCacheKey方法的典型用法代码示例。如果您正苦于以下问题:PHP FileRepo::getLocalCacheKey方法的具体用法?PHP FileRepo::getLocalCacheKey怎么用?PHP FileRepo::getLocalCacheKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileRepo
的用法示例。
在下文中一共展示了FileRepo::getLocalCacheKey方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getDescriptionText
/**
* Get the HTML text of the description page, if available
*
* @return string
*/
function getDescriptionText()
{
global $wgMemc, $wgLang;
if (!$this->repo || !$this->repo->fetchDescription) {
return false;
}
$renderUrl = $this->repo->getDescriptionRenderUrl($this->getName(), $wgLang->getCode());
if ($renderUrl) {
if ($this->repo->descriptionCacheExpiry > 0) {
wfDebug("Attempting to get the description from cache...");
$key = $this->repo->getLocalCacheKey('RemoteFileDescription', 'url', $wgLang->getCode(), $this->getName());
$obj = $wgMemc->get($key);
if ($obj) {
wfDebug("success!\n");
return $obj;
}
wfDebug("miss\n");
}
wfDebug("Fetching shared description from {$renderUrl}\n");
$res = Http::get($renderUrl);
if ($res && $this->repo->descriptionCacheExpiry > 0) {
$wgMemc->set($key, $res, $this->repo->descriptionCacheExpiry);
}
return $res;
} else {
return false;
}
}
示例2: getDescriptionText
/**
* Get the HTML text of the description page, if available
*
* @param bool|Language $lang Optional language to fetch description in
* @return string
*/
function getDescriptionText($lang = false)
{
global $wgLang;
if (!$this->repo || !$this->repo->fetchDescription) {
return false;
}
$lang = $lang ?: $wgLang;
$renderUrl = $this->repo->getDescriptionRenderUrl($this->getName(), $lang->getCode());
if ($renderUrl) {
$cache = ObjectCache::getMainWANInstance();
$key = null;
if ($this->repo->descriptionCacheExpiry > 0) {
wfDebug("Attempting to get the description from cache...");
$key = $this->repo->getLocalCacheKey('RemoteFileDescription', 'url', $lang->getCode(), $this->getName());
$obj = $cache->get($key);
if ($obj) {
wfDebug("success!\n");
return $obj;
}
wfDebug("miss\n");
}
wfDebug("Fetching shared description from {$renderUrl}\n");
$res = Http::get($renderUrl, array(), __METHOD__);
if ($res && $key) {
$cache->set($key, $res, $this->repo->descriptionCacheExpiry);
}
return $res;
} else {
return false;
}
}
示例3: getDescriptionText
/**
* Get the HTML text of the description page, if available
*
* @param bool|Language $lang Optional language to fetch description in
* @return string
*/
function getDescriptionText($lang = false)
{
global $wgLang;
if (!$this->repo || !$this->repo->fetchDescription) {
return false;
}
$lang = $lang ?: $wgLang;
$renderUrl = $this->repo->getDescriptionRenderUrl($this->getName(), $lang->getCode());
if ($renderUrl) {
$cache = ObjectCache::getMainWANInstance();
$key = $this->repo->getLocalCacheKey('RemoteFileDescription', 'url', $lang->getCode(), $this->getName());
return $cache->getWithSetCallback($key, $this->repo->descriptionCacheExpiry ?: $cache::TTL_UNCACHEABLE, function ($oldValue, &$ttl, array &$setOpts) use($renderUrl) {
wfDebug("Fetching shared description from {$renderUrl}\n");
$res = Http::get($renderUrl, [], __METHOD__);
if (!$res) {
$ttl = WANObjectCache::TTL_UNCACHEABLE;
}
return $res;
});
}
return false;
}