当前位置: 首页>>代码示例>>PHP>>正文


PHP wfSharedMemcKey函数代码示例

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


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

示例1: getArticleData

 protected function getArticleData($pageId)
 {
     global $wgVideoHandlersVideosMigrated;
     $oTitle = Title::newFromID($pageId);
     $oMemCache = F::App()->wg->memc;
     $sKey = wfSharedMemcKey('category_exhibition_article_cache_0', $pageId, F::App()->wg->cityId, $this->isVerify(), $wgVideoHandlersVideosMigrated ? 1 : 0, $this->getTouched($oTitle));
     $cachedResult = $oMemCache->get($sKey);
     if (!empty($cachedResult)) {
         return $cachedResult;
     }
     $snippetText = '';
     $imageUrl = $this->getImageFromPageId($pageId);
     // if category has no images in page content, look for images and articles in category
     if ($imageUrl == '') {
         $resultArray = $this->getCategoryImageOrSnippet($pageId);
         $snippetText = $resultArray['snippetText'];
         $imageUrl = $resultArray['imageUrl'];
         if (empty($snippetText) && empty($imageUrl)) {
             $snippetService = new ArticleService($oTitle);
             $snippetText = $snippetService->getTextSnippet();
         }
     }
     $returnData = array('id' => $pageId, 'title' => $oTitle->getText(), 'url' => $oTitle->getFullURL(), 'img' => $imageUrl, 'width' => $this->thumbWidth, 'height' => $this->thumbHeight, 'sortType' => $this->getSortType(), 'displayType' => $this->getDisplayType(), 'snippet' => $snippetText);
     // will be purged elsewhere after edit
     $oMemCache->set($sKey, $returnData, 60 * 60 * 24 * 7);
     return $returnData;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:27,代码来源:CategoryExhibitionSectionSubcategories.class.php

示例2: getGlobalFooterLinks

 private function getGlobalFooterLinks()
 {
     global $wgCityId, $wgContLang, $wgLang, $wgMemc;
     wfProfileIn(__METHOD__);
     $verticalId = WikiFactoryHub::getInstance()->getVerticalId($wgCityId);
     $memcKey = wfSharedMemcKey(self::MEMC_KEY_GLOBAL_FOOTER_LINKS, $wgContLang->getCode(), $wgLang->getCode(), $verticalId, self::MEMC_KEY_GLOBAL_FOOTER_VERSION);
     $globalFooterLinks = $wgMemc->get($memcKey);
     if (!empty($globalFooterLinks)) {
         wfProfileOut(__METHOD__);
         return $globalFooterLinks;
     }
     if (is_null($globalFooterLinks = getMessageAsArray(self::MESSAGE_KEY_GLOBAL_FOOTER_LINKS . '-' . $verticalId))) {
         if (is_null($globalFooterLinks = getMessageAsArray(self::MESSAGE_KEY_GLOBAL_FOOTER_LINKS))) {
             wfProfileOut(__METHOD__);
             WikiaLogger::instance()->error("Global Footer's links not found in messages", ['exception' => new Exception()]);
             return [];
         }
     }
     $parsedLinks = [];
     foreach ($globalFooterLinks as $link) {
         $link = trim($link);
         if (strpos($link, '*') === 0) {
             $parsedLink = parseItem($link);
             if (strpos($parsedLink['text'], 'LICENSE') !== false || $parsedLink['text'] == 'GFDL') {
                 $parsedLink['isLicense'] = true;
             } else {
                 $parsedLink['isLicense'] = false;
             }
             $parsedLinks[] = $parsedLink;
         }
     }
     $wgMemc->set($memcKey, $parsedLinks, self::MEMC_EXPIRY);
     wfProfileOut(__METHOD__);
     return $parsedLinks;
 }
开发者ID:yusufchang,项目名称:app,代码行数:35,代码来源:GlobalFooterController.class.php

示例3: getExternalData

 protected function getExternalData()
 {
     global $wgCityId;
     // Prevent recursive loop
     if ($wgCityId == self::EXTERNAL_DATA_SOURCE_WIKI_ID) {
         return array();
     }
     if (self::$externalData === false) {
         global $wgLang, $wgMemc;
         $code = $wgLang->getCode();
         $key = wfSharedMemcKey('user-command-special-page', 'lang', $code);
         $data = $wgMemc->get($key);
         if (empty($data)) {
             $data = array();
             $external = Http::get($this->getExternalDataUrl($code));
             $external = json_decode($external, true);
             if (is_array($external) && !empty($external['allOptions']) && is_array($external['allOptions'])) {
                 foreach ($external['allOptions'] as $option) {
                     $data[$option['id']] = $option;
                 }
             }
             $wgMemc->set($key, $data, self::EXTERNAL_DATA_CACHE_TTL);
         }
         self::$externalData = $data;
     }
     return self::$externalData;
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:27,代码来源:SpecialPageUserCommand.php

示例4: testCache

 /**
  * @group UsingDB
  */
 public function testCache()
 {
     $user = $this->getTestUser();
     //create object here, so we use the same one all the time, that way we can test local cache
     $object = new UserService();
     $cachedLocalUser = $this->invokePrivateMethod('UserService', 'getUserFromLocalCacheById', $user->getId(), $object);
     $cachedLocalUserByName = $this->invokePrivateMethod('UserService', 'getUserFromLocalCacheByName', $user->getName(), $object);
     //values are not cached localy yet
     $this->assertEquals(false, $cachedLocalUser);
     $this->assertEquals(false, $cachedLocalUserByName);
     //cache user, both locally and mem cached
     $this->invokePrivateMethod('UserService', 'cacheUser', $user, $object);
     //do the assertion again, local cache should have hit one
     $cachedLocalUser = $this->invokePrivateMethod('UserService', 'getUserFromLocalCacheById', $user->getId(), $object);
     $cachedLocalUserByName = $this->invokePrivateMethod('UserService', 'getUserFromLocalCacheByName', $user->getName(), $object);
     $this->assertEquals($user, $cachedLocalUser);
     $this->assertEquals($user, $cachedLocalUserByName);
     //check if user was cached in memcache, use new object for that
     $cachedMemCacheById = $this->invokePrivateMethod('UserService', 'getUserFromMemCacheById', $user->getId());
     $cachedMemCacheByName = $this->invokePrivateMethod('UserService', 'getUserFromMemCacheByName', $user->getName());
     $this->assertEquals($user, $cachedMemCacheById);
     $this->assertEquals($user, $cachedMemCacheByName);
     //need for deleting form cache test values
     $sharedIdKey = wfSharedMemcKey("UserCache:" . $user->getId());
     $sharedNameKey = wfSharedMemcKey("UserCache:" . $user->getName());
     //remove user from memcache
     F::app()->wg->memc->delete($sharedIdKey);
     F::app()->wg->memc->delete($sharedNameKey);
     //do assert against memcache again
     $cachedMemCacheById = $this->invokePrivateMethod('UserService', 'getUserFromMemCacheById', $user->getId());
     $cachedMemCacheByName = $this->invokePrivateMethod('UserService', 'getUserFromMemCacheByName', $user->getName());
     $this->assertEquals(false, $cachedMemCacheById);
     $this->assertEquals(false, $cachedMemCacheByName);
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:37,代码来源:UserServiceTest.php

示例5: getAllComponents

 /**
  * @desc Returns an array with all available components configuration
  *
  * @return array
  */
 public function getAllComponents()
 {
     $components = WikiaDataAccess::cache(wfSharedMemcKey(__CLASS__, 'all_components_list_with_details', self::MEMCACHE_VERSION_KEY, $this->userLangCode), Wikia\UI\Factory::MEMCACHE_EXPIRATION, [$this, 'getAllComponentsFromDirectories']);
     $this->initComponents($components);
     $this->includeComponentsAssets($components);
     return $components;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:12,代码来源:StyleguideComponents.class.php

示例6: getCommercialUseNotAllowedWikis

 public function getCommercialUseNotAllowedWikis()
 {
     if (empty(self::$wikiList)) {
         self::$wikiList = WikiaDataAccess::cache(wfSharedMemcKey(self::CACHE_KEY_COMMERCIAL_NOT_ALLOWED), self::CACHE_VALID_TIME, function () {
             return $this->getWikisWithVar();
         });
     }
     return self::$wikiList;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:9,代码来源:LicensedWikisService.class.php

示例7: getGameCacheValue

 public function getGameCacheValue()
 {
     $factory = new ScavengerHuntGames();
     $gameId = $this->getVal('gameId', '');
     $readWrite = $this->getVal('readwrite', 0);
     $key = wfSharedMemcKey('ScavengerHuntGameIndex', $gameId, $readWrite ? 1 : 0, ScavengerHuntGames::CACHE_VERSION);
     $this->setVal('key', $key);
     $this->setVal('response', unserialize($factory->getCache()->get($key)));
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:9,代码来源:ScavengerHuntController.class.php

示例8: __construct

 function __construct($cache, $key)
 {
     $this->memc = $cache;
     if (empty($key)) {
         throw new Exception('Key is empty');
     }
     $this->key = $key;
     $this->lockKey = wfSharedMemcKey('MemcacheSyncLock', $key);
     $this->instance = uniqid('', true);
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:10,代码来源:MemcacheSync.class.php

示例9: get

 /**
  * @param int $articleId
  * @param int $limit - max limit = 10
  * @return array of articles with details
  */
 public function get($articleId, $limit)
 {
     wfProfileIn(__METHOD__);
     $hubName = $this->getHubName();
     $lang = $this->getContentLangCode();
     $out = \WikiaDataAccess::cache(\wfSharedMemcKey('RecommendationApi', self::RECOMMENDATION_ENGINE, $hubName, $lang, self::MCACHE_VERSION), \WikiaResponse::CACHE_STANDARD, function () use($hubName, $lang) {
         $topArticles = $this->getTopArticles($hubName, $lang);
         return $this->getArticlesInfo($topArticles);
     });
     shuffle($out);
     $out = array_slice($out, 0, $limit);
     wfProfileOut(__METHOD__);
     return $out;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:19,代码来源:TopArticles.class.php

示例10: getMemcKey

 /**
  * Return memcache key used for given message / variable
  *
  * City ID can be specified to return key for different wiki
  *
  * @param string $messageName message / variable name
  * @param int|bool $cityId city ID (false - default to current wiki)
  * @return string memcache key
  */
 private function getMemcKey($messageName, $cityId = false)
 {
     if ($this->useSharedMemcKey) {
         $wikiId = substr(wfSharedMemcKey(), 0, -1);
     } else {
         $wikiId = is_numeric($cityId) ? $cityId : intval($this->wg->CityId);
         // fix for internal and staff (BugId:15149)
         if ($wikiId == 0) {
             $wikiId = $this->wg->DBname;
         }
     }
     $messageName = str_replace(' ', '_', $messageName);
     return implode(':', array(__CLASS__, $wikiId, $this->wg->Lang->getCode(), $messageName, self::version));
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:23,代码来源:NavigationModel.class.php

示例11: onWikiFactoryVarChanged

 public static function onWikiFactoryVarChanged($cv_name, $city_id, $value)
 {
     $app = F::app();
     if (self::isWikiaBarConfig($city_id, $cv_name)) {
         Wikia::log(__METHOD__, '', 'Updating WikiaBar config caches after change');
         foreach ($value as $vertical => $languages) {
             foreach ($languages as $language => $content) {
                 $dataMemcKey = wfSharedMemcKey('WikiaBarContents', $vertical, $language, WikiaBarModel::WIKIA_BAR_MCACHE_VERSION);
                 Wikia::log(__METHOD__, '', 'Purging ' . $dataMemcKey);
                 $app->wg->memc->set($dataMemcKey, null);
             }
         }
     }
     return true;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:15,代码来源:WikiaBarHooks.class.php

示例12: index

	public function index() {
		global $wgCityId, $wgLang, $wgContLang, $wgMemc;
		$catId = WikiFactoryHub::getInstance()->getCategoryId( $wgCityId );
		$mKey = wfSharedMemcKey( 'mOasisFooterLinks', $wgContLang->getCode(), $wgLang->getCode(), $catId );

		$this->footer_links = $wgMemc->get( $mKey );
		$this->copyright = RequestContext::getMain()->getSkin()->getCopyright();

		if ( empty( $this->footer_links ) ) {
			$this->footer_links = $this->getWikiaFooterLinks();
			$wgMemc->set( $mKey, $this->footer_links, 86400 );
		}

		$this->hub = $this->getHub();
	}
开发者ID:schwarer2006,项目名称:wikia,代码行数:15,代码来源:CorporateFooterController.class.php

示例13: generateList

 /**
  * @access private
  *
  * @param String $format	format of list: csv or xml
  */
 private function generateList($format)
 {
     global $wgOut, $wgMemc, $wgExternalSharedDB;
     $res = $wgMemc->get(wfSharedMemcKey("{$format}-city-list"));
     $filename = "{$format}_city_list.{$format}";
     $wgOut->disable();
     if ($format === "xml") {
         header("Content-type: application/xml; charset=UTF-8");
     } else {
         header("Content-type: text/csv; charset=UTF-8");
     }
     $wgOut->sendCacheControl();
     print gzinflate($res);
     exit;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:20,代码来源:SpecialNewWikis_body.php

示例14: getImageSrcByTitle

 public static function getImageSrcByTitle($cityId, $articleTitle, $width = null, $height = null)
 {
     global $wgMemc;
     wfProfileIn(__METHOD__);
     $imageKey = wfSharedMemcKey('image_url_from_wiki', $cityId . $articleTitle . $width . $height);
     $imageSrc = $wgMemc->get($imageKey);
     if ($imageSrc === false) {
         $globalFile = GlobalFile::newFromText($articleTitle, $cityId);
         if ($globalFile->exists()) {
             $imageSrc = $globalFile->getCrop($width, $height);
         } else {
             $imageSrc = null;
         }
         $wgMemc->set($imageKey, $imageSrc, 60 * 60 * 24 * 3);
     }
     wfProfileOut(__METHOD__);
     return $imageSrc;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:18,代码来源:ImagesService.class.php

示例15: generateList

function generateList($format)
{
    global $wgMemc, $wgExternalSharedDB;
    $func = "begin_" . $format;
    $res = $func();
    $dbr = WikiFactory::db(DB_SLAVE, array(), $wgExternalSharedDB);
    $sth = $dbr->select(array("city_list"), array("city_title", "city_lang", "city_url", "city_id"), array("city_public = 1"), __METHOD__);
    while ($row = $dbr->fetchObject($sth)) {
        $row->category = WikiFactory::getCategory($row->city_id);
        $func = "body_" . $format;
        $res .= $func($row);
    }
    $func = "end_" . $format;
    $res .= $func();
    if (!empty($res)) {
        $gz_res = gzdeflate($res, 3);
        $wgMemc->set(wfSharedMemcKey("{$format}-city-list"), $gz_res, 3600 * 6);
    }
}
开发者ID:Tjorriemorrie,项目名称:app,代码行数:19,代码来源:newWikis.php


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