本文整理汇总了PHP中wfGetCache函数的典型用法代码示例。如果您正苦于以下问题:PHP wfGetCache函数的具体用法?PHP wfGetCache怎么用?PHP wfGetCache使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wfGetCache函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* @params include:
* - objectCache : Name of an object cache registered in $wgObjectCaches.
* This defaults to the one specified by $wgMainCacheType.
* - cacheTTL : Seconds to cache the aggregate data before regenerating.
* @param array $params
*/
protected function __construct(array $params)
{
parent::__construct($params);
$this->cache = isset($params['objectCache']) ? wfGetCache($params['objectCache']) : wfGetMainCache();
$this->cacheTTL = isset($params['cacheTTL']) ? $params['cacheTTL'] : 180;
// 3 min
}
示例2: setUp
/**
* Prepares the environment before running a test.
*/
protected function setUp()
{
global $wgMemc;
parent::setUp();
$this->user = User::newFromName("someReviewer");
$wgMemc = wfGetCache(CACHE_DB);
}
示例3: getInlineScript
/**
* Get contents of a javascript file for inline use.
*
* Roughly based MediaWiki core methods:
* - ResourceLoader::filter()
* - ResourceLoaderFileModule::readScriptFiles()
*
* @param string $name Path to file relative to /modules/inline/
* @return string Minified script
* @throws Exception If file doesn't exist
*/
protected static function getInlineScript($name)
{
// Get file
$filePath = __DIR__ . '/../../modules/inline/' . $name;
if (!file_exists($filePath)) {
throw new Exception(__METHOD__ . ": file not found: \"{$filePath}\"");
}
$contents = file_get_contents($filePath);
// Try minified from cache
$key = wfMemcKey('centralauth', 'minify-js', md5($contents));
$cache = wfGetCache(CACHE_ANYTHING);
$cacheEntry = $cache->get($key);
if (is_string($cacheEntry)) {
return $cacheEntry;
}
// Compute new value
$result = '';
try {
$result = JavaScriptMinifier::minify($contents) . "\n/* cache key: {$key} */";
$cache->set($key, $result);
} catch (Exception $e) {
MWExceptionHandler::logException($e);
wfDebugLog('CentralAuth', __METHOD__ . ": minification failed for {$name}: {$e}");
$result = ResourceLoader::formatException($e) . "\n" . $contents;
}
return $result;
}
示例4: newInstance
/**
* @since 1.21
* @deprecated 1.25 Construct a SiteStore instance directly instead.
*
* @param ORMTable|null $sitesTable
* @param BagOStuff|null $cache
*
* @return SiteStore
*/
public static function newInstance(ORMTable $sitesTable = null, BagOStuff $cache = null)
{
if ($cache === null) {
$cache = wfGetCache(wfIsHHVM() ? CACHE_ACCEL : CACHE_ANYTHING);
}
$siteStore = new DBSiteStore();
return new static($siteStore, $cache);
}
示例5: __construct
/**
* Constructor.
* @param string $title
* @param integer $revision
* @param ObjectCache $cache: (optional) cache client.
* @param Http $http: (optional) HTTP client.
*/
function __construct($title, $revision, $cache = NULL, $http = NULL)
{
global $wgEventLoggingDBname;
$this->title = $title;
$this->revision = $revision;
$this->cache = $cache ?: wfGetCache(CACHE_ANYTHING);
$this->http = $http ?: new Http();
$this->key = "schema:{$wgEventLoggingDBname}:{$title}:{$revision}";
}
示例6: __construct
function __construct($memCached, $useDB, $expiry)
{
if (!$memCached) {
$memCached = wfGetCache(CACHE_NONE);
}
$this->mMemc = $memCached;
$this->mDisable = !$useDB;
$this->mExpiry = $expiry;
}
示例7: setUp
protected function setUp()
{
parent::setUp();
global $wgHooks;
$this->setMwGlobals(array('wgHooks' => $wgHooks, 'wgTranslateTranslationServices' => array()));
$wgHooks['TranslatePostInitGroups'] = array(array($this, 'getTestGroups'));
$mg = MessageGroups::singleton();
$mg->setCache(wfGetCache('hash'));
$mg->recache();
}
示例8: run
function run() {
global $wgUser;
// Initialization
$title = $this->title;
// Other stuff
$user = $this->getUser();
$summary = $this->getSummary();
$base = $this->getBase();
PageTranslationHooks::$allowTargetEdit = true;
$oldUser = $wgUser;
$wgUser = $user;
$error = '';
$article = new Article( $title, 0 );
$ok = $article->doDeleteArticle( $summary, false, 0, true, $error );
if ( !$ok ) {
$logger = new LogPage( 'pagetranslation' );
$params = array(
'user' => $this->getPerformer(),
'target' => $base,
'error' => base64_encode( serialize( $ok ) ), // This is getting ridiculous
);
$doer = User::newFromName( $this->getPerformer() );
$msg = $this->getFull() ? 'deletefnok' : 'deletelnok';
$logger->addEntry( $msg, $title, null, array( serialize( $params ) ), $doer );
}
PageTranslationHooks::$allowTargetEdit = false;
$cache = wfGetCache( CACHE_DB );
$pages = (array) $cache->get( wfMemcKey( 'pt-base', $base ) );
$lastitem = array_pop( $pages );
if ( $title->getPrefixedText() === $lastitem ) {
$cache->delete( wfMemcKey( 'pt-base', $base ) );
$logger = new LogPage( 'pagetranslation' );
$params = array( 'user' => $this->getPerformer() );
$doer = User::newFromName( $this->getPerformer() );
$msg = $this->getFull() ? 'deletefok' : 'deletelok';
$logger->addEntry( $msg, Title::newFromText( $base ), null, array( serialize( $params ) ), $doer );
$tpage = TranslatablePage::newFromTitle( $title );
$tpage->getTranslationPercentages( true );
foreach ( $tpage->getTranslationPages() as $page ) {
$page->invalidateCache();
}
$title->invalidateCache();
}
$wgUser = $oldUser;
return true;
}
示例9: setUp
protected function setUp()
{
parent::setUp();
global $wgHooks;
$this->setMwGlobals(array('wgHooks' => $wgHooks, 'wgGroupPermissions' => array(), 'wgTranslateMessageNamespaces' => array(NS_MEDIAWIKI)));
$wgHooks['TranslatePostInitGroups'] = array(array($this, 'getTestGroups'));
$mg = MessageGroups::singleton();
$mg->setCache(wfGetCache('hash'));
$mg->recache();
MessageIndex::setInstance(new HashMessageIndex());
MessageIndex::singleton()->rebuild();
}
示例10: setUp
public function setUp()
{
parent::setUp();
global $wgHooks;
$this->setMwGlobals(array('wgHooks' => $wgHooks, 'wgTranslateTranslationServices' => array(), 'wgTranslateDelayedMessageIndexRebuild' => false));
$wgHooks['TranslatePostInitGroups'] = array();
$mg = MessageGroups::singleton();
$mg->setCache(wfGetCache('hash'));
$mg->recache();
MessageIndex::setInstance(new HashMessageIndex());
MessageIndex::singleton()->rebuild();
}
示例11: setUp
protected function setUp()
{
parent::setUp();
global $wgHooks;
$this->setMwGlobals(array('wgHooks' => $wgHooks, 'wgTranslateTranslationServices' => array(), 'wgTranslateCacheDirectory' => $this->getNewTempDirectory()));
$wgHooks['TranslatePostInitGroups'] = array();
$mg = MessageGroups::singleton();
$mg->setCache(wfGetCache('hash'));
$mg->recache();
MessageIndex::setInstance(new HashMessageIndex());
MessageIndex::singleton()->rebuild();
}
示例12: checkRateLimit
/**
* Implement a rudimentary rate limiting system,
* we can't use User::pingLImiter() because stewards
* have the "noratelimit" userright
*
* Hardcoded to allow 1 merge per 60 seconds
*
* @return bool true if we should let the user proceed
*/
private function checkRateLimit()
{
$cache = wfGetCache(CACHE_ANYTHING);
$key = 'centralauth:usermerge:' . md5($this->getUser()->getName());
$found = $cache->get($key);
if ($found === false) {
$cache->set($key, true, 60);
return true;
} else {
return false;
}
}
示例13: setUp
protected function setUp()
{
parent::setUp();
$conf = array(__DIR__ . '/data/ParentGroups.yaml');
global $wgHooks;
$this->setMwGlobals(array('wgHooks' => $wgHooks, 'wgTranslateGroupFiles' => $conf, 'wgTranslateTranslationServices' => array()));
$wgHooks['TranslatePostInitGroups'] = array('MessageGroups::getConfiguredGroups');
$mg = MessageGroups::singleton();
$mg->setCache(wfGetCache('hash'));
$mg->recache();
MessageIndex::setInstance(new HashMessageIndex());
MessageIndex::singleton()->rebuild();
}
示例14: setUp
protected function setUp()
{
parent::setUp();
global $wgHooks, $wgTranslateTranslationServices, $wgTranslateTestTTMServer;
$this->setMwGlobals(array('wgHooks' => $wgHooks, 'wgTranslateTranslationServices' => array()));
$wgTranslateTranslationServices['TTMServer'] = $wgTranslateTestTTMServer;
$wgHooks['TranslatePostInitGroups'] = array(array($this, 'addGroups'));
$mg = MessageGroups::singleton();
$mg->setCache(wfGetCache('hash'));
$mg->recache();
MessageIndex::setInstance(new HashMessageIndex());
MessageIndex::singleton()->rebuild();
}
示例15: __construct
function __construct()
{
$this->cache = wfGetCache(CACHE_ANYTHING);
// if (HuijiPrefix::hasPrefix($prefix)){
// $this->mPrefix = $prefix;
// } else {
// $this->mPrefix = '';
// }
// $this->cache = wfGetCache( CACHE_ANYTHING );
// $this->loadFromRow();
// $siteCache = self::getSiteCache();
// $siteCache->set($this->mPrefix, $this);
}