/** * @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"); } }
} $res = $mcc->get($args[0]); $hv = $mcc->_hashfunc($args[0]); for ($i = 0; $i < 3; $i++) { print $mcc->_buckets[$hv % $mcc->_bucketcount] . "\n"; $hv += $mcc->_hashfunc($i . $args[0]); } break; case 'set': $key = array_shift($args); if ($args[0] == "#" && is_numeric($args[1])) { $value = str_repeat('*', $args[1]); } else { $value = implode(' ', $args); } if (!$mcc->set($key, $value, 0)) { # print 'Error: ' . $mcc->error_string() . "\n"; print "MemCached error\n"; } break; case 'delete': $key = implode(' ', $args); if (!$mcc->delete($key)) { # print 'Error: ' . $mcc->error_string() . "\n"; print "MemCached error\n"; } break; case 'history': if (function_exists('readline_list_history')) { foreach (readline_list_history() as $num => $line) { print "{$num}: {$line}\n";
public function set($key, $value, $exptime = 0, $flags = 0) { return $this->client->set($this->validateKeyEncoding($key), $value, $this->fixExpiry($exptime)); }