本文整理汇总了PHP中wfSharedMemcKey函数的典型用法代码示例。如果您正苦于以下问题:PHP wfSharedMemcKey函数的具体用法?PHP wfSharedMemcKey怎么用?PHP wfSharedMemcKey使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wfSharedMemcKey函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: initFromCookie
public function initFromCookie()
{
global $wgMemc, $wgDBcluster, $wgCookiePrefix, $wgRequest;
wfDebug(__METHOD__ . " \n");
if (wfReadOnly()) {
wfDebug(__METHOD__ . ": Cannot load from session - DB is running with the --read-only option ");
return false;
}
// Copy safety check from User.php
$uid = intval(isset($_COOKIE["{$wgCookiePrefix}UserID"]) ? $_COOKIE["{$wgCookiePrefix}UserID"] : 0);
if ($uid != 0 && isset($_SESSION['wsUserID']) && $uid != $_SESSION['wsUserID']) {
$wgRequest->response()->setcookie("UserID", '', time() - 86400);
$wgRequest->response()->setcookie("UserName", '', time() - 86400);
$wgRequest->response()->setcookie("_session", '', time() - 86400);
$wgRequest->response()->setcookie("Token", '', time() - 86400);
trigger_error("###INEZ### {$_SESSION['wsUserID']}\n", E_USER_WARNING);
return false;
}
wfDebug(__METHOD__ . ": user from session: {$uid} \n");
if (empty($uid)) {
return false;
}
// exists on central
$this->initFromId($uid);
// exists on local
$User = null;
if (!empty($this->mRow)) {
$memkey = sprintf("extuser:%d:%s", $this->getId(), $wgDBcluster);
$user_touched = $wgMemc->get($memkey);
if ($user_touched != $this->getUserTouched()) {
$_key = wfSharedMemcKey("user_touched", $this->getId());
wfDebug(__METHOD__ . ": user touched is different on central and {$wgDBcluster} \n");
wfDebug(__METHOD__ . ": clear {$_key} \n");
$wgMemc->set($memkey, $this->getUserTouched());
$wgMemc->delete($_key);
} else {
$User = $this->getLocalUser();
}
}
wfDebug(__METHOD__ . ": return user object \n");
return is_null($User);
}
开发者ID:schwarer2006,项目名称:wikia,代码行数:42,代码来源:ExternalUser_Wikia.php
示例17: get_data
public function get_data()
{
wfProfileIn(__METHOD__);
// get data
$curdate = date('Ymd');
$memKey = wfSharedMemcKey('customreport', $this->code, $curdate, $this->days);
$this->data = $this->wg->Memc->get($memKey);
if (!is_array($this->data)) {
$this->data = $this->{'get_' . $this->code}();
$this->patch_zero();
$this->wg->Memc->set($memKey, $this->data, 3600 * 24);
}
// convert array to xml
$xml = array();
foreach ($this->data as $key => $value) {
$xml[] = $this->convertDataToXML($key, $value);
}
wfProfileOut(__METHOD__);
return $xml;
}
开发者ID:Tjorriemorrie,项目名称:app,代码行数:20,代码来源:Report.class.php
示例18: getData
private function getData()
{
global $wgMemc;
static $localCache;
if ($localCache) {
return $localCache;
}
$now = $this->getCurrentTimestamp();
$memKey = wfSharedMemcKey('adengine', __METHOD__, self::CACHE_BUSTER);
$cached = $wgMemc->get($memKey);
if (is_array($cached) && $cached['ttl'] > $now) {
// Cache hit!
$localCache = $cached;
return $cached;
}
// Cache miss, need to re-download the scripts
$generated = $this->generateData();
if ($generated === false) {
// HTTP request didn't work
if (is_array($cached)) {
// Oh, we still have the thing cached
// Let's use the script for the next a few minutes
$cached['ttl'] = $now + self::TTL_GRACE;
$wgMemc->set($memKey, $cached);
$localCache = $cached;
return $cached;
}
$error = 'Failed to download SevenOne Media files and had no cached script';
$data = ['script' => 'var SEVENONEMEDIA_ERROR = ' . json_encode($error) . ';', 'modTime' => $now, 'ttl' => $now + self::TTL_GRACE];
$wgMemc->set($memKey, $data);
$localCache = $data;
return $data;
}
$data = ['script' => $generated, 'modTime' => $now, 'ttl' => $now + self::TTL_SCRIPTS];
if ($generated === $cached['script']) {
$data['modTime'] = $cached['modTime'];
}
$wgMemc->set($memKey, $data);
$localCache = $data;
return $data;
}
开发者ID:Tjorriemorrie,项目名称:app,代码行数:41,代码来源:ResourceLoaderAdEngineSevenOneMediaModule.php
示例19: getDetails
/**
* Get details about one or more wikis
*
* @param Array $wikiIds An array of one or more wiki ID's
* @param bool $getBlocked If set to true, will return also blocked (not displayed on global page) wikias
*
* @return Array A collection of results, the index is the wiki ID and each item has a name,
* url, lang, hubId, headline, desc, image and flags index.
*/
public function getDetails(array $wikiIds = null, $getBlocked = false)
{
wfProfileIn(__METHOD__);
$results = array();
if (!empty($wikiIds)) {
$notFound = array();
foreach ($wikiIds as $index => $val) {
$val = (int) $val;
if (!empty($val)) {
$cacheKey = wfSharedMemcKey(__METHOD__, self::CACHE_VERSION, $val);
$item = $this->wg->Memc->get($cacheKey);
if (is_array($item)) {
$results[$val] = $item;
} else {
$notFound[] = $val;
}
}
}
$wikiIds = $notFound;
}
if (!empty($wikiIds)) {
$db = $this->getSharedDB();
$where = array('city_list.city_public' => 1, 'city_list.city_id IN (' . implode(',', $wikiIds) . ')');
if (!$getBlocked) {
$where[] = '((city_visualization.city_flags & ' . self::FLAG_BLOCKED . ') != ' . self::FLAG_BLOCKED . ' OR city_visualization.city_flags IS NULL)';
}
$rows = $db->select(array('city_visualization', 'city_list'), array('city_list.city_id', 'city_list.city_title', 'city_list.city_url', 'city_visualization.city_lang_code', 'city_visualization.city_vertical', 'city_visualization.city_headline', 'city_visualization.city_description', 'city_visualization.city_main_image', 'city_visualization.city_flags'), $where, __METHOD__, array(), array('city_visualization' => array('LEFT JOIN', 'city_list.city_id = city_visualization.city_id')));
while ($row = $db->fetchObject($rows)) {
$item = array('name' => $row->city_title, 'url' => $row->city_url, 'lang' => $row->city_lang_code, 'hubId' => $row->city_vertical, 'headline' => $row->city_headline, 'desc' => $row->city_description, 'image' => PromoImage::fromPathname($row->city_main_image)->ensureCityIdIsSet($row->city_id)->getPathname(), 'flags' => array('official' => ($row->city_flags & self::FLAG_OFFICIAL) == self::FLAG_OFFICIAL, 'promoted' => ($row->city_flags & self::FLAG_PROMOTED) == self::FLAG_PROMOTED));
$cacheKey = wfSharedMemcKey(__METHOD__, self::CACHE_VERSION, $row->city_id);
$this->wg->Memc->set($cacheKey, $item, 43200);
$results[$row->city_id] = $item;
}
}
wfProfileOut(__METHOD__);
return $results;
}
开发者ID:Tjorriemorrie,项目名称:app,代码行数:46,代码来源:WikisModel.class.php
示例20: isWikiExists
private static function isWikiExists($sName)
{
global $wgExternalSharedDB, $wgMemc;
$cacheKey = wfSharedMemcKey(__METHOD__ . ':' . $sName);
$cachedValue = $wgMemc->get($cacheKey);
if (is_numeric($cachedValue)) {
if ($cachedValue > 0) {
return $cachedValue;
} else {
return false;
}
}
$DBr = wfGetDB(DB_SLAVE, array(), $wgExternalSharedDB);
$dbResult = $DBr->Query('SELECT city_id' . ' FROM city_domains' . ' WHERE city_domain = ' . $DBr->AddQuotes("{$sName}.wikia.com") . ' LIMIT 1' . ';', __METHOD__);
if ($row = $DBr->FetchObject($dbResult)) {
$DBr->FreeResult($dbResult);
$wgMemc->set($cacheKey, intval($row->city_id), self::IS_WIKI_EXISTS_CACHE_TTL);
return intval($row->city_id);
} else {
$DBr->FreeResult($dbResult);
$wgMemc->set($cacheKey, 0, self::IS_WIKI_EXISTS_CACHE_TTL);
return false;
}
}
开发者ID:Tjorriemorrie,项目名称:app,代码行数:24,代码来源:SpecialInterwikiDispatcher_body.php
注:本文中的wfSharedMemcKey函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论