Пример #1
0
 /**
  * Retrieve the ParserOutput from ParserCache.
  * false if not found or outdated.
  *
  * @param WikiPage|Article $article
  * @param ParserOptions $popts
  * @param bool $useOutdated (default false)
  *
  * @return ParserOutput|bool False on failure
  */
 public function get($article, $popts, $useOutdated = false)
 {
     global $wgCacheEpoch;
     $canCache = $article->checkTouched();
     if (!$canCache) {
         // It's a redirect now
         return false;
     }
     $touched = $article->getTouched();
     $parserOutputKey = $this->getKey($article, $popts, $useOutdated);
     if ($parserOutputKey === false) {
         wfIncrStats('pcache.miss.absent');
         return false;
     }
     $value = $this->mMemc->get($parserOutputKey);
     if (!$value) {
         wfDebug("ParserOutput cache miss.\n");
         wfIncrStats("pcache.miss.absent");
         return false;
     }
     wfDebug("ParserOutput cache found.\n");
     // The edit section preference may not be the appropiate one in
     // the ParserOutput, as we are not storing it in the parsercache
     // key. Force it here. See bug 31445.
     $value->setEditSectionTokens($popts->getEditSection());
     $wikiPage = method_exists($article, 'getPage') ? $article->getPage() : $article;
     if (!$useOutdated && $value->expired($touched)) {
         wfIncrStats("pcache.miss.expired");
         $cacheTime = $value->getCacheTime();
         wfDebug("ParserOutput key expired, touched {$touched}, " . "epoch {$wgCacheEpoch}, cached {$cacheTime}\n");
         $value = false;
     } elseif ($value->isDifferentRevision($article->getLatest())) {
         wfIncrStats("pcache.miss.revid");
         $revId = $article->getLatest();
         $cachedRevId = $value->getCacheRevisionId();
         wfDebug("ParserOutput key is for an old revision, latest {$revId}, cached {$cachedRevId}\n");
         $value = false;
     } elseif (Hooks::run('RejectParserCacheValue', array($value, $wikiPage, $popts)) === false) {
         wfIncrStats('pcache.miss.rejected');
         wfDebug("ParserOutput key valid, but rejected by RejectParserCacheValue hook handler.\n");
         $value = false;
     } else {
         wfIncrStats("pcache.hit");
     }
     return $value;
 }
Пример #2
0
 /**
  * Retrieve the ParserOutput from ParserCache.
  * false if not found or outdated.
  *
  * @param Article $article
  * @param ParserOptions $popts
  * @param bool $useOutdated (default false)
  *
  * @return ParserOutput|bool False on failure
  */
 public function get($article, $popts, $useOutdated = false)
 {
     global $wgCacheEpoch;
     wfProfileIn(__METHOD__);
     $canCache = $article->checkTouched();
     if (!$canCache) {
         // It's a redirect now
         wfProfileOut(__METHOD__);
         return false;
     }
     $touched = $article->getTouched();
     $parserOutputKey = $this->getKey($article, $popts, $useOutdated);
     if ($parserOutputKey === false) {
         wfIncrStats('pcache_miss_absent');
         wfProfileOut(__METHOD__);
         return false;
     }
     $value = $this->mMemc->get($parserOutputKey);
     if (!$value) {
         wfDebug("ParserOutput cache miss.\n");
         wfIncrStats("pcache_miss_absent");
         wfProfileOut(__METHOD__);
         return false;
     }
     wfDebug("ParserOutput cache found.\n");
     // The edit section preference may not be the appropiate one in
     // the ParserOutput, as we are not storing it in the parsercache
     // key. Force it here. See bug 31445.
     $value->setEditSectionTokens($popts->getEditSection());
     if (!$useOutdated && $value->expired($touched)) {
         wfIncrStats("pcache_miss_expired");
         $cacheTime = $value->getCacheTime();
         wfDebug("ParserOutput key expired, touched {$touched}, " . "epoch {$wgCacheEpoch}, cached {$cacheTime}\n");
         $value = false;
     } elseif ($value->isDifferentRevision($article->getLatest())) {
         wfIncrStats("pcache_miss_revid");
         $revId = $article->getLatest();
         $cachedRevId = $value->getCacheRevisionId();
         wfDebug("ParserOutput key is for an old revision, latest {$revId}, cached {$cachedRevId}\n");
         $value = false;
     } else {
         wfIncrStats("pcache_hit");
     }
     wfProfileOut(__METHOD__);
     return $value;
 }
Пример #3
0
 }
 $args = explode(' ', $line);
 $command = array_shift($args);
 // process command
 switch ($command) {
     case 'help':
         // show an help message
         mccShowHelp(array_shift($args));
         break;
     case 'get':
         $sub = '';
         if (array_key_exists(1, $args)) {
             $sub = $args[1];
         }
         print "Getting {$args[0]}[{$sub}]\n";
         $res = $mcc->get($args[0]);
         if (array_key_exists(1, $args)) {
             $res = $res[$args[1]];
         }
         if ($res === false) {
             # print 'Error: ' . $mcc->error_string() . "\n";
             print "MemCached error\n";
         } elseif (is_string($res)) {
             print "{$res}\n";
         } else {
             var_dump($res);
         }
         break;
     case 'getsock':
         $res = $mcc->get($args[0]);
         $sock = $mcc->get_sock($args[0]);
Пример #4
0
 protected function getWithToken($key, &$casToken, $flags = 0)
 {
     return $this->client->get($this->validateKeyEncoding($key), $casToken);
 }
Пример #5
0
 protected function getWithToken($key, &$casToken, $flags = 0)
 {
     return $this->client->get($this->encodeKey($key), $casToken);
 }