• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP wfMemcKey函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中wfMemcKey函数的典型用法代码示例。如果您正苦于以下问题:PHP wfMemcKey函数的具体用法?PHP wfMemcKey怎么用?PHP wfMemcKey使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了wfMemcKey函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: WidgetFounderBadge

function WidgetFounderBadge($id, $params)
{
    $output = "";
    wfProfileIn(__METHOD__);
    global $wgMemc;
    $key = wfMemcKey("WidgetFounderBadge", "user");
    $user = $wgMemc->get($key);
    if (is_null($user)) {
        global $wgCityId;
        $user = WikiFactory::getWikiById($wgCityId)->city_founding_user;
        $wgMemc->set($key, $user, 3600);
    }
    if (0 == $user) {
        return wfMsgForContent("widget-founderbadge-notavailable");
    }
    $key = wfMemcKey("WidgetFounderBadge", "edits");
    $edits = $wgMemc->get($key);
    if (empty($edits)) {
        $edits = AttributionCache::getInstance()->getUserEditPoints($user);
        $wgMemc->set($key, $edits, 300);
    }
    $author = array("user_id" => $user, "user_name" => User::newFromId($user)->getName(), "edits" => $edits);
    $output = Answer::getUserBadge($author);
    wfProfileOut(__METHOD__);
    return $output;
}
开发者ID:schwarer2006,项目名称:wikia,代码行数:26,代码来源:WidgetFounderBadge.php


示例2: execute

 /**
  * Generates feed's content
  *
  * @param $feed ChannelFeed subclass object (generally the one returned by getFeedObject())
  * @param $rows ResultWrapper object with rows in recentchanges table
  * @param $lastmod Integer: timestamp of the last item in the recentchanges table (only used for the cache key)
  * @param $opts FormOptions as in SpecialRecentChanges::getDefaultOptions()
  * @return null or true
  */
 public function execute($feed, $rows, $lastmod, $opts)
 {
     global $messageMemc, $wgFeedCacheTimeout;
     global $wgSitename, $wgLang;
     if (!FeedUtils::checkFeedOutput($this->format)) {
         return;
     }
     $timekey = wfMemcKey($this->type, $this->format, 'timestamp');
     $optionsHash = md5(serialize($opts->getAllValues()));
     $key = wfMemcKey($this->type, $this->format, $wgLang->getCode(), $optionsHash);
     FeedUtils::checkPurge($timekey, $key);
     /*
      * Bumping around loading up diffs can be pretty slow, so where
      * possible we want to cache the feed output so the next visitor
      * gets it quick too.
      */
     $cachedFeed = $this->loadFromCache($lastmod, $timekey, $key);
     if (is_string($cachedFeed)) {
         wfDebug("RC: Outputting cached feed\n");
         $feed->httpHeaders();
         echo $cachedFeed;
     } else {
         wfDebug("RC: rendering new feed and caching it\n");
         ob_start();
         self::generateFeed($rows, $feed);
         $cachedFeed = ob_get_contents();
         ob_end_flush();
         $this->saveToCache($cachedFeed, $timekey, $key);
     }
     return true;
 }
开发者ID:rocLv,项目名称:conference,代码行数:40,代码来源:ChangesFeed.php


示例3: WidgetCategoryCloud

function WidgetCategoryCloud($id, $params)
{
    $output = "";
    wfProfileIn(__METHOD__);
    global $wgMemc;
    $key = wfMemcKey("WidgetCategoryCloud", "data");
    $data = $wgMemc->get($key);
    if (is_null($data)) {
        $data = WidgetCategoryCloudCloudizeData(WidgetCategoryCloudGetData());
        $wgMemc->set($key, $data, 3600);
    }
    if (empty($data)) {
        wfProfileOut(__METHOD__);
        return wfMsgForContent("widget-categorycloud-empty");
    }
    foreach ($data as $name => $value) {
        $category = Title::newFromText($name, NS_CATEGORY);
        if (is_object($category)) {
            $class = "cloud" . $value;
            $output .= Xml::openElement("li", array("class" => $class));
            // FIXME fix Wikia:link and use it here
            $output .= Xml::element("a", array("class" => $class, "href" => $category->getLocalURL(), "title" => $category->getFullText()), $category->getBaseText());
            $output .= Xml::closeElement("li");
            $output .= "\n";
        }
    }
    if (empty($output)) {
        wfProfileOut(__METHOD__);
        return wfMsgForContent("widget-categorycloud-empty");
    }
    $output = Xml::openElement("ul") . $output . Xml::closeElement("ul");
    wfProfileOut(__METHOD__);
    return $output;
}
开发者ID:Tjorriemorrie,项目名称:app,代码行数:34,代码来源:WidgetCategoryCloud.php


示例4: wfNumberOfWikisAssignValue

function wfNumberOfWikisAssignValue(&$parser, &$cache, &$magicWordId, &$ret)
{
    global $wgMemc;
    if ($magicWordId == 'NUMBEROFWIKIS') {
        $key = wfMemcKey('shoutwiki', 'numberofwikis');
        $data = $wgMemc->get($key);
        if ($data != '') {
            // We have it in cache? Oh goody, let's just use the cached value!
            wfDebugLog('NumberOfWikis', 'Got the amount of wikis from memcached');
            // return value
            $ret = $data;
        } else {
            // Not cached → have to fetch it from the database
            $dbr = wfGetDB(DB_SLAVE);
            $res = $dbr->select('wiki_list', 'COUNT(*) AS count', array('wl_deleted' => 0), __METHOD__);
            wfDebugLog('NumberOfWikis', 'Got the amount of wikis from DB');
            foreach ($res as $row) {
                // Store the count in cache...
                // (86400 = seconds in a day)
                $wgMemc->set($key, $row->count, 86400);
                // ...and return the value to the user
                $ret = $row->count;
            }
        }
    }
    return true;
}
开发者ID:schwarer2006,项目名称:wikia,代码行数:27,代码来源:NumberOfWikis.php


示例5: updateMainEditsCount

 /**
  * Perform the queries necessary to update the social point counts and
  * purge memcached entries.
  */
 function updateMainEditsCount()
 {
     global $wgOut, $wgNamespacesForEditPoints;
     $whereConds = array();
     $whereConds[] = 'rev_user <> 0';
     // If points are given out for editing non-main namespaces, take that
     // into account too.
     if (isset($wgNamespacesForEditPoints) && is_array($wgNamespacesForEditPoints)) {
         foreach ($wgNamespacesForEditPoints as $pointNamespace) {
             $whereConds[] = 'page_namespace = ' . (int) $pointNamespace;
         }
     }
     $dbw = wfGetDB(DB_MASTER);
     $res = $dbw->select(array('revision', 'page'), array('rev_user_text', 'rev_user', 'COUNT(*) AS the_count'), $whereConds, __METHOD__, array('GROUP BY' => 'rev_user_text'), array('page' => array('INNER JOIN', 'page_id = rev_page')));
     foreach ($res as $row) {
         $user = User::newFromId($row->rev_user);
         $user->loadFromId();
         if (!$user->isAllowed('bot')) {
             $editCount = $row->the_count;
         } else {
             $editCount = 0;
         }
         $s = $dbw->selectRow('user_stats', array('stats_user_id'), array('stats_user_id' => $row->rev_user), __METHOD__);
         if (!$s->stats_user_id || $s === false) {
             $dbw->insert('user_stats', array('stats_year_id' => 0, 'stats_user_id' => $row->rev_user, 'stats_user_name' => $row->rev_user_text, 'stats_total_points' => 1000), __METHOD__);
         }
         $wgOut->addHTML("<p>Updating {$row->rev_user_text} with {$editCount} edits</p>");
         $dbw->update('user_stats', array('stats_edit_count = ' . $editCount), array('stats_user_id' => $row->rev_user), __METHOD__);
         global $wgMemc;
         // clear stats cache for current user
         $key = wfMemcKey('user', 'stats', $row->rev_user);
         $wgMemc->delete($key);
     }
 }
开发者ID:kghbln,项目名称:semantic-social-profile,代码行数:38,代码来源:SpecialUpdateEditCounts.php


示例6: __construct

 /**
  * Constructor
  *
  * @param $langobj The Language Object
  * @param $maincode String: the main language code of this language
  * @param $variants Array: the supported variants of this language
  * @param $variantfallbacks Array: the fallback language of each variant
  * @param $flags Array: defining the custom strings that maps to the flags
  * @param $manualLevel Array: limit for supported variants
  */
 public function __construct($langobj, $maincode, $variants = array(), $variantfallbacks = array(), $flags = array(), $manualLevel = array())
 {
     $this->mLangObj = $langobj;
     $this->mMainLanguageCode = $maincode;
     global $wgDisabledVariants;
     $this->mVariants = array();
     foreach ($variants as $variant) {
         if (!in_array($variant, $wgDisabledVariants)) {
             $this->mVariants[] = $variant;
         }
     }
     $this->mVariantFallbacks = $variantfallbacks;
     global $wgLanguageNames;
     $this->mVariantNames = $wgLanguageNames;
     $this->mCacheKey = wfMemcKey('conversiontables', $maincode);
     $f = array('A' => 'A', 'T' => 'T', 'R' => 'R', 'D' => 'D', '-' => '-', 'H' => 'H', 'N' => 'N');
     $this->mFlags = array_merge($f, $flags);
     foreach ($this->mVariants as $v) {
         if (array_key_exists($v, $manualLevel)) {
             $this->mManualLevel[$v] = $manualLevel[$v];
         } else {
             $this->mManualLevel[$v] = 'bidirectional';
         }
         $this->mNamespaceTables[$v] = array();
         $this->mFlags[$v] = $v;
     }
 }
开发者ID:BackupTheBerlios,项目名称:swahili-dict,代码行数:37,代码来源:LanguageConverter.php


示例7: wfProxyCheck

/**
 * Forks processes to scan the originating IP for an open proxy server
 * MemCached can be used to skip IPs that have already been scanned
 */
function wfProxyCheck()
{
    global $wgBlockOpenProxies, $wgProxyPorts, $wgProxyScriptPath;
    global $wgUseMemCached, $wgMemc, $wgProxyMemcExpiry;
    global $wgProxyKey;
    if (!$wgBlockOpenProxies) {
        return;
    }
    $ip = wfGetIP();
    # Get MemCached key
    $skip = false;
    if ($wgUseMemCached) {
        $mcKey = wfMemcKey('proxy', 'ip', $ip);
        $mcValue = $wgMemc->get($mcKey);
        if ($mcValue) {
            $skip = true;
        }
    }
    # Fork the processes
    if (!$skip) {
        $title = Title::makeTitle(NS_SPECIAL, 'Blockme');
        $iphash = md5($ip . $wgProxyKey);
        $url = $title->getFullURL('ip=' . $iphash);
        foreach ($wgProxyPorts as $port) {
            $params = implode(' ', array(escapeshellarg($wgProxyScriptPath), escapeshellarg($ip), escapeshellarg($port), escapeshellarg($url)));
            exec("php {$params} &>/dev/null &");
        }
        # Set MemCached key
        if ($wgUseMemCached) {
            $wgMemc->set($mcKey, 1, $wgProxyMemcExpiry);
        }
    }
}
开发者ID:puring0815,项目名称:OpenKore,代码行数:37,代码来源:ProxyTools.php


示例8: getTodaysTotal

 /**
  * Get the total amount of money raised for today
  * @param string $timeZoneOffset The timezone to request the total for
  * @param string $today The current date in the requested time zone, e.g. '2011-12-16'
  * @param int $fudgeFactor How much to adjust the total by
  * @return integer
  */
 private function getTodaysTotal($timeZoneOffset, $today, $fudgeFactor = 0)
 {
     global $wgMemc, $egFundraiserStatisticsMinimum, $egFundraiserStatisticsMaximum, $egFundraiserStatisticsCacheTimeout;
     // Delete this block once there is timezone support in the populating script
     $setTimeZone = date_default_timezone_set('UTC');
     $today = date('Y-m-d');
     // Get the current date in UTC
     $timeZoneOffset = '+00:00';
     $key = wfMemcKey('fundraiserdailytotal', $timeZoneOffset, $today, $fudgeFactor);
     $cache = $wgMemc->get($key);
     if ($cache != false && $cache != -1) {
         return $cache;
     }
     // Use MediaWiki slave database
     $dbr = wfGetDB(DB_SLAVE);
     $result = $dbr->select('public_reporting_days', 'round( prd_total ) AS total', array('prd_date' => $today), __METHOD__);
     $row = $dbr->fetchRow($result);
     if ($row['total'] > 0) {
         $total = $row['total'];
     } else {
         $total = 0;
     }
     // Make sure the fudge factor is a number
     if (is_nan($fudgeFactor)) {
         $fudgeFactor = 0;
     }
     // Add the fudge factor to the total
     $total += $fudgeFactor;
     $wgMemc->set($key, $total, $egFundraiserStatisticsCacheTimeout);
     return $total;
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:38,代码来源:DailyTotal_body.php


示例9: memcacheKey

 public static function memcacheKey()
 {
     // mech: bugfix for 19619 in getTemplateData method requires me to invalidate the cache,
     // so I'm changing the memkey
     $mKey = wfMemcKey('mOasisLatestPhotosKey' . self::MEMC_KEY_VER);
     return $mKey;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:7,代码来源:LatestPhotosController.class.php


示例10: set

 static function set($title, $content)
 {
     global $wgRevisionCacheExpiry, $wgMemc;
     if (!$wgRevisionCacheExpiry) {
         // caching is not possible
         return false;
     }
     // we need to assign a sequence to revision text, because
     // Article::loadContent expects page.text_id to be an integer.
     $seq_key = wfMemcKey('offline', 'textid_seq');
     if (!$wgMemc->get($seq_key)) {
         $wgMemc->set($seq_key, 1);
     }
     // and clear the cache??
     $textid = $wgMemc->incr($seq_key);
     // cache a lookup from title to fake textid
     $titlekey = wfMemcKey('textid', 'titlehash', md5($title));
     $wgMemc->set($titlekey, $textid, $wgRevisionCacheExpiry);
     // TODO interfering with the cache is necessary to avoid a
     // second query on Revision::newFromId.  It would be much
     // smarter to directly retrieve article markup, and optionally
     // cache in the usual way.
     $textkey = wfMemcKey('revisiontext', 'textid', $textid);
     $wgMemc->delete($textkey);
     $wgMemc->set($textkey, $content, $wgRevisionCacheExpiry);
     //wfDebug('Stuffing the cache with '.strlen($content).' bytes, at id='.$textid."\n");
     return $textid;
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:28,代码来源:CachedStorage.php


示例11: testFifoLineAndMemcClear

	function testFifoLineAndMemcClear() {
		global $wgMemc;
		$startTime = 100;
		$timeSample = 5;
		$fifoLength = 60;
		$key = wfMemcKey( "hp_stats_test", "stat_hp_fifo_week" );
		$wgMemc->set( $key,array(),60);

		$startTime += 1;
		$out = HomePageStatisticCollector::fifoLine(1,$timeSample,$fifoLength,$key,$startTime);
		$this->assertEquals( 1,$out);
		$startTime += 15;
		$out = HomePageStatisticCollector::fifoLine(2,$timeSample,$fifoLength,$key,$startTime);
		$this->assertEquals( 3,$out);
		$startTime += 105;
		$out = HomePageStatisticCollector::fifoLine(3,$timeSample,$fifoLength,$key,$startTime);
		$this->assertEquals( 5,$out);
		$wgMemc->delete($key);


		$title = "corporatepage-test-msg";
		$text = "";
		$key = wfMemcKey( "hp_msg_parser",  $title, 'en' ) ;
		$wgMemc->set($key,"test value",30);

		$this->assertEquals("test value", $wgMemc->get($key));
		CorporatePageHelper::clearMessageCache($title,$text);
		$this->assertNull($wgMemc->get($key));
	}
开发者ID:schwarer2006,项目名称:wikia,代码行数:29,代码来源:CorporatePageTest.php


示例12: getInterfaceObjectFromType

 protected function getInterfaceObjectFromType($type)
 {
     wfProfileIn(__METHOD__);
     $apiUrl = $this->getApiUrl();
     if (empty($this->videoId)) {
         throw new EmptyResponseException($apiUrl);
     }
     $memcKey = wfMemcKey(static::$CACHE_KEY, $apiUrl, static::$CACHE_KEY_VERSION);
     $processedResponse = F::app()->wg->memc->get($memcKey);
     if (empty($processedResponse)) {
         $req = MWHttpRequest::factory($apiUrl, array('noProxy' => true));
         $req->setHeader('User-Agent', self::$REQUEST_USER_AGENT);
         $status = $req->execute();
         if ($status->isOK()) {
             $response = $req->getContent();
             $this->response = $response;
             // Only for migration purposes
             if (empty($response)) {
                 throw new EmptyResponseException($apiUrl);
             } else {
                 if ($req->getStatus() == 301) {
                     throw new VideoNotFoundException($req->getStatus(), $this->videoId . ' Moved Permanently.', $apiUrl);
                 }
             }
         } else {
             $this->checkForResponseErrors($req->status, $req->getContent(), $apiUrl);
         }
         $processedResponse = $this->processResponse($response, $type);
         F::app()->wg->memc->set($memcKey, $processedResponse, static::$CACHE_EXPIRY);
     }
     wfProfileOut(__METHOD__);
     return $processedResponse;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:33,代码来源:GamestarApiWrapper.class.php


示例13: 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;
 }
开发者ID:NDKilla,项目名称:mediawiki-extensions-CentralAuth,代码行数:38,代码来源:SpecialCentralAutoLogin.php


示例14: onArticleSaveComplete

 /**
  * @param $article Article
  * @param $user User
  * @param $text
  * @param $summary
  * @param $minoredit
  * @param $watchthis
  * @param $sectionanchor
  * @param $flags
  * @param $revision
  * @param $status
  * @param $baseRevId
  * @return bool
  */
 static function onArticleSaveComplete(&$article, &$user, $text, $summary, $minoredit, $watchthis, $sectionanchor, &$flags, $revision, &$status, $baseRevId)
 {
     global $wgMemc;
     $mKey = wfMemcKey('mOasisRelatedPages', $article->mTitle->getArticleId());
     $wgMemc->delete($mKey);
     return true;
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:21,代码来源:RelatedPagesController.class.php


示例15: getArticleQuality

 /**
  * Returns percentile quality of articleId or null if not found
  * @return int|null
  */
 public function getArticleQuality()
 {
     $cacheKey = wfMemcKey(__CLASS__, self::CACHE_BUSTER, $this->articleId);
     $percentile = $this->app->wg->Memc->get($cacheKey);
     if ($percentile === false) {
         $title = Title::newFromID($this->articleId);
         if ($title === null) {
             return null;
         }
         $article = new Article($title);
         $parserOutput = $article->getParserOutput();
         if (!$parserOutput) {
             //MAIN-3592
             $this->error(__METHOD__, ['message' => 'Article::getParserOutput returned false', 'articleId' => $this->articleId]);
             return null;
         }
         $inputs = ['outbound' => 0, 'inbound' => 0, 'length' => 0, 'sections' => 0, 'images' => 0];
         /**
          *  $title->getLinksTo() and  $title->getLinksFrom() function are
          * too expensive to call it here as we want only the number of links
          */
         $inputs['outbound'] = $this->countOutboundLinks($this->articleId);
         $inputs['inbound'] = $this->countInboundLinks($this->articleId);
         $inputs['sections'] = count($parserOutput->getSections());
         $inputs['images'] = count($parserOutput->getImages());
         $inputs['length'] = $this->getCharsCountFromHTML($parserOutput->getText());
         $quality = $this->computeFormula($inputs);
         $percentile = $this->searchPercentile($quality);
         $this->app->wg->Memc->set($cacheKey, $percentile, self::MEMC_CACHE_TIME);
     }
     return $percentile;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:36,代码来源:ArticleQualityService.php


示例16: section

 /**
  * @desc Related pages are lazy-loaded on article pages for mobile, oasis and monobook. However, there are extensions
  * dependent on this method where related pages module isn't lazy-loaded such as: FilePage (FilePageController.class.php)
  */
 public function section()
 {
     global $wgTitle, $wgContentNamespaces, $wgRequest, $wgMemc;
     // request params
     $altTitle = $this->request->getVal('altTitle', null);
     $relatedPages = RelatedPages::getInstance();
     $anyNs = $this->request->getVal('anyNS', false);
     $title = empty($altTitle) ? $wgTitle : $altTitle;
     $articleid = $title->getArticleId();
     if (!$anyNs) {
         $ignoreNS = !empty($wgTitle) && in_array($wgTitle->getNamespace(), $wgContentNamespaces);
     } else {
         $ignoreNS = false;
     }
     $this->skipRendering = Wikia::isMainPage() || $ignoreNS || count($relatedPages->getCategories($articleid)) == 0 || $wgRequest->getVal('action', 'view') != 'view' || $relatedPages->isRendered();
     if (!$this->skipRendering) {
         $mKey = wfMemcKey('mOasisRelatedPages', $articleid, self::MEMC_KEY_VER);
         $this->pages = $wgMemc->get($mKey);
         $this->srcAttrName = $this->app->checkSkin('monobook') ? 'src' : 'data-src';
         if (empty($this->pages)) {
             $this->pages = $relatedPages->get($articleid);
             if (count($this->pages) > 0) {
                 $wgMemc->set($mKey, $this->pages, 3 * 3600);
             } else {
                 $this->skipRendering = true;
             }
         }
     }
     $this->mobileSkin = false;
     $this->relatedPagesHeading = wfMessage('wikiarelatedpages-heading')->plain();
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:35,代码来源:RelatedPagesController.class.php


示例17: purgeStaleMemcachedText

function purgeStaleMemcachedText() {
	global $wgMemc, $wgDBname;
	$db = wfGetDB( DB_MASTER );
	$maxTextId = $db->selectField( 'text', 'max(old_id)' );
	$latestReplicatedTextId = $db->selectField( array( 'recentchanges', 'revision' ), 'rev_text_id',
		array( 'rev_id = rc_this_oldid', "rc_timestamp < '20101225183000'"),  'purgeStaleMemcachedText',
		array( 'ORDER BY' => 'rc_timestamp DESC' ) );
	$latestReplicatedTextId -= 100; # A bit of paranoia

	echo "Going to purge text entries from $latestReplicatedTextId to $maxTextId in $wgDBname\n";

	for ( $i = $latestReplicatedTextId; $i < $maxTextId; $i++ ) {
		$keys = array();
		$keys[] = wfMemcKey( 'flaggedrevs', 'countPending', $i );
		$keys[] = wfMemcKey( 'flaggedrevs', 'includesSynced', $i );
		$keys[] = wfMemcKey( 'flaggedrevs', 'overrideRedirect', $i );
		$keys[] = wfMemcKey( 'unreviewedPages', 'underReview', $i );

		foreach ( $keys as $key ) {
			while (1) {
				if (! $wgMemc->delete( $key ) ) {
					echo "Memcache delete for $key returned false\n";
				}
				if ( $wgMemc->get( $key ) ) {
					echo "There's still content in $key!\n";
				} else {
					break;
				}
			}
		}
	}
}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:32,代码来源:purgeStaleMemcachedFlaggedRevs.php


示例18: wfProxyCheck

/**
 * Forks processes to scan the originating IP for an open proxy server
 * MemCached can be used to skip IPs that have already been scanned
 */
function wfProxyCheck()
{
    global $wgBlockOpenProxies, $wgProxyPorts, $wgProxyScriptPath;
    global $wgMemc, $wgProxyMemcExpiry, $wgRequest;
    global $wgProxyKey;
    if (!$wgBlockOpenProxies) {
        return;
    }
    $ip = $wgRequest->getIP();
    # Get MemCached key
    $mcKey = wfMemcKey('proxy', 'ip', $ip);
    $mcValue = $wgMemc->get($mcKey);
    $skip = (bool) $mcValue;
    # Fork the processes
    if (!$skip) {
        $title = SpecialPage::getTitleFor('Blockme');
        $iphash = md5($ip . $wgProxyKey);
        $url = wfExpandUrl($title->getFullURL('ip=' . $iphash), PROTO_HTTP);
        foreach ($wgProxyPorts as $port) {
            $params = implode(' ', array(escapeshellarg($wgProxyScriptPath), escapeshellarg($ip), escapeshellarg($port), escapeshellarg($url)));
            exec("php {$params} >" . wfGetNull() . " 2>&1 &");
        }
        # Set MemCached key
        $wgMemc->set($mcKey, 1, $wgProxyMemcExpiry);
    }
}
开发者ID:Tarendai,项目名称:spring-website,代码行数:30,代码来源:ProxyTools.php


示例19: saveQuizAsBlob

 private function saveQuizAsBlob($name, $icon, $quiz)
 {
     if (empty($name) || empty($quiz)) {
         return;
     }
     $quiz_array = array('quiz_name' => $name, 'quiz_icon' => $icon, 'quiz_data' => json_encode($quiz), 'quiz_stamp' => wfTimestampNow());
     $dbr = wfGetDB(DB_SLAVE);
     $dbw = wfGetDB(DB_MASTER);
     //is that quiz already in there?
     $count = $dbr->selectField('quizzes', 'count(*) as count', array('quiz_name' => $name), __METHOD);
     if ($count > 0) {
         //it's there. update it...
         $res = $dbw->update('quizzes', $quiz_array, array('quiz_name' => $name), __METHOD__);
         self::$import_array[] = 'UPDATED: http://www.wikihow.com/Quiz/' . $name;
     } else {
         //brand spanking new (so to speak)
         $res = $dbw->insert('quizzes', $quiz_array, __METHOD__);
         self::$import_array[] = 'NEW: http://www.wikihow.com/Quiz/' . $name;
     }
     //delete any cached version of these exists just to be safe
     global $wgMemc;
     $memkey = wfMemcKey('quiz', $name);
     $wgMemc->delete($memkey);
     print 'QUIZ: ' . $name . "\n";
 }
开发者ID:biribogos,项目名称:wikihow-src,代码行数:25,代码来源:QuizImport.php


示例20: getMonthViews

 protected static function getMonthViews(Title $title)
 {
     global $wgMemc;
     $key = wfMemcKey('pvi', 'month', md5($title->getPrefixedText()));
     $data = $wgMemc->get($key);
     if ($data) {
         return $data;
     }
     $today = date('Ymd');
     $lastMonth = date('Ymd', time() - 60 * 60 * 24 * 30);
     $url = self::buildApiUrl($title, $lastMonth, $today);
     $req = MWHttpRequest::factory($url, ['timeout' => 10], __METHOD__);
     $status = $req->execute();
     if (!$status->isOK()) {
         LoggerFactory::getInstance('PageViewInfo')->error("Failed fetching {$url}: {$status->getWikiText()}", ['url' => $url, 'title' => $title->getPrefixedText()]);
         return false;
     }
     $data = FormatJson::decode($req->getContent(), true);
     // Add our start/end periods
     $data['start'] = $lastMonth;
     $data['end'] = $today;
     // Cache for an hour
     $wgMemc->set($key, $data, 60 * 60);
     return $data;
 }
开发者ID:wikimedia,项目名称:mediawiki-extensions-WikimediaPageViewInfo,代码行数:25,代码来源:PageViewInfo.hooks.php



注:本文中的wfMemcKey函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP wfMemoryLimit函数代码示例发布时间:2022-05-23
下一篇:
PHP wfMatchesDomainList函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap