From 7248aeaaff322b1000bfc2fe87aa1fea75fc4c3b Mon Sep 17 00:00:00 2001 From: Alexandre Emsenhuber Date: Sat, 1 Mar 2008 15:08:49 +0000 Subject: [PATCH] * Update docs/memcached.txt * Kill call to $wgUseMemCached in includes/ProxyTools.php --- docs/memcached.txt | 189 +++++++++++++++++++++++++++++++++------- includes/ProxyTools.php | 17 ++-- 2 files changed, 163 insertions(+), 43 deletions(-) diff --git a/docs/memcached.txt b/docs/memcached.txt index 3addd965c2..1f5ba09fad 100644 --- a/docs/memcached.txt +++ b/docs/memcached.txt @@ -78,53 +78,180 @@ subdirectory under the present one. We intend to track updates, but if you want to check for the lastest released version, see http://www.danga.com/memcached/apis.bml -If you don't set $wgUseMemCached, we still create a MemCacheClient, +MediaWiki use three object for memcached: +* $wgMemc, controlled by $wgMainCacheType +* $parserMemc, controlled by $wgParserCacheType +* $messageMemc, controlled by $wgMessageCacheType +If you set CACHE_NONE to one of the three control variable, (default +value for $wgMainCacheType), MediaWiki still create a MemCacheClient, but requests to it are no-ops and we always fall through to the database. If the cache daemon can't be contacted, it should also disable itself fairly smoothly. +By default, $wgMemc is used but when it is $parserMemc or $messageMemc +this is mentionned below. + == Keys used == -User: - key: $wgDBname:user:id:$sId - ex: wikidb:user:id:51 - stores: instance of class User - set in: User::loadFromSession() - cleared by: User::saveSettings(), UserTalkUpdate::doUpdate() - -Newtalk: - key: $wgDBname:newtalk:ip:$ip - ex: wikidb:newtalk:ip:123.45.67.89 - stores: integer, 0 or 1 - set in: User::loadFromDatabase() - cleared by: User::saveSettings() # ? - expiry set to 30 minutes +Ajax Search: + key: $wgDBname:ajaxsearch:md5( $search ) + ex: wikidb:ajaxsearch: + stores: array with the result of research of a given text + cleared by: nothing + expiry: 30 minutes + +Date Formatter: + key: $wgDBname:dateformatter + ex: wikidb:dateformatter + stores: a single instance of the DateFormatter class + cleared by: nothing + expiry: one hour + +Difference Engine: + key: $wgDBname:diff:version:{MW_DIFF_VERSION}:oldid:$old:newid:$new + ex: wikidb:diff:version:1.11a:oldid:1:newid:2 + stores: body of a difference + cleared by: nothing + expiry: one week + +Interwiki: + key: $wgDBname:interwiki:$prefix + ex: wikidb:interwiki:w + stores: object from the interwiki table of the database + expiry: $wgInterwikiExpiry + cleared by: nothing + +Lag time of the databases: + key: $wgDBname:lag_times + ex: wikidb:lag_times + stores: array mapping the database id to its lag time + expriy: 5 secondes + cleared by: nothing -LinkCache: +Link Cache: + controlled by: $wgLinkCacheMemcached key: $wgDBname:lc:title:$title ex: wikidb:lc:title:Wikipedia:Welcome,_Newcomers! stores: cur_id of page, or 0 if page does not exist set in: LinkCache::addLink() + expriry: one day cleared by: LinkCache::clearBadLink() should be cleared on page deletion and rename -MediaWiki namespace: - key: $wgDBname:messages - ex: wikidb:messages + +Localisation: + key: $wgDBname:localisation:$lang + ex: wikidb:localisation:de + stores: array of localisation settings + set in: Language::loadLocalisation() + expiry: none + cleared by: Language::loadLocalisation() + +Message Cache: + stored in: $parserMemc + key: $wgDBname:messages, $wgDBname:messages-hash, $wgDBname:messages-status + ex: wikidb:messages, wikidb:messages-hash, wikidb:messages-status stores: an array where the keys are DB keys and the values are messages set in: wfMsg(), Article::editUpdates() both call wfLoadAllMessages() + expriy: $wgMsgCacheExpiry + cleared by: nothing + +Newtalk: + key: $wgDBname:newtalk:ip:$ip + ex: wikidb:newtalk:ip:123.45.67.89 + stores: integer, 0 or 1 + set in: User::loadFromDatabase() + cleared by: User::saveSettings() # ? + expiry: 30 minutes + +Parser Cache: + stored in: $parserMemc + controlled by: $wgEnableParserCache + key: $wgDBname:pcache:idhash:$pageid-$renderkey!$hash$edit + $pageid: id of the page + $renderkey: 1 if action=render, 0 otherwise + $hash: hash of user options, see User::getPageRenderingHash() + $edit: '!edit=0' if the user can't edit the page, '' otherwise + ex: wikidb:pcache:idhash:1-0!1!0!!en!2 + stores: ParserOutput object + modified by: Article::editUpdates() + expriy: $wgParserCacheExpireTime or one hour if it contains specific magic + words + +Ping limiter: + controlled by: $wgRateLimits + key: $wgDBname:limiter:action:$action:ip:$ip, + $wgDBname:limiter:action:$action:user:$id, + mediawiki:limiter:action:$action:ip:$ip and + mediawiki:limiter:action:$action:subnet:$sub + ex: wikidb:limiter:action:edit:ip:123.45.67.89, + wikidb:limiter:action:edit:user:1012 + mediawiki:limiter:action:edit:ip:123.45.67.89 and + mediawiki:limiter:action:$action:subnet:123.45.67 + stores: number of action made by user/ip/subnet + cleared by: nothing + expiry: expiry set for the action and group in $wgRateLimits + + +Proxy Check: (deprecated) + key: $wgDBname:proxy:ip:$ip + ex: wikidb:proxy:ip:123.45.67.89 + stores: 1 if the ip is a proxy cleared by: nothing + expiry: $wgProxyMemcExpiry -Watchlist: - key: $wgDBname:watchlist:id:$userID - ex: wikidb:watchlist:id:4635 - stores: HTML string - cleared by: nothing, expiry time $wgWLCacheTimeout (1 hour) - note: emergency optimisation only - -IP blocks: - key: $wgDBname:ipblocks - ex: wikidb:ipblocks - stores: array of arrays, for the BlockCache class - cleared by: BlockCache:clear() +Revision text: + key: $wgDBname:revisiontext:textid:$id + ex: wikidb:revisiontext:textid:1012 + stores: text of a revision + cleared by: nothing + expriry: $wgRevisionCacheExpiry + +Sessions: + controlled by: $wgSessionsInMemcached + key: $wgBDname:session:$id + ex: wikidb:session:38d7c5b8d3bfc51egf40c69bc40f8be3 + stores: $SESSION, useful when using a multi-sever wiki + expriy: one hour + cleared by: session_destroy() + +Sidebar: + stored in: $parserMemc + controlled by: $wgEnableSidebarCache + key: $wgDBname:sidebar + ex: wikidb:sidebar + stores: the html output of the sidebar + expriy: $wgSidebarCacheExpiry + cleared by: MessageCache::replace() + +Special:Allpages: + key: $wgDBname:allpages:ns:$ns + ex: wikidb:allpages:ns:0 + stores: array of pages in a namespace + expiry: one hour + cleared by: nothing + +Special:Recentchanges (feed): + stored in: $messageMemc + key: $wgDBname:rcfeed:$format:limit:$imit:minor:$hideminor and + rcfeed:$format:timestamp + ex: wikidb:rcfeed:rss:limit:50:minor:0 and rcfeed:rss:timestamp + stores: xml output of feed + expiry: one day + clear by: calling Special:Recentchanges?action=purge + +Statistics: + controlled by: $wgStatsMethod + key: $wgDBname:stats:$key + ex: wikibd:stats:request_with_session + stores: counter for statistics (see maintenance/stats.php script) + expiry: none (?) + cleared by: maintenance/clear_stats.php script + +User: + key: $wgDBname:user:id:$sId + ex: wikidb:user:id:51 + stores: instance of class User + set in: User::saveToCache() + cleared by: User::saveSettings(), User::clearSharedCache() ... more to come ... \ No newline at end of file diff --git a/includes/ProxyTools.php b/includes/ProxyTools.php index 6585de428c..cdaafbe677 100644 --- a/includes/ProxyTools.php +++ b/includes/ProxyTools.php @@ -130,7 +130,7 @@ function wfIsTrustedProxy( $ip ) { */ function wfProxyCheck() { global $wgBlockOpenProxies, $wgProxyPorts, $wgProxyScriptPath; - global $wgUseMemCached, $wgMemc, $wgProxyMemcExpiry; + global $wgMemc, $wgProxyMemcExpiry; global $wgProxyKey; if ( !$wgBlockOpenProxies ) { @@ -140,14 +140,9 @@ function wfProxyCheck() { $ip = wfGetIP(); # Get MemCached key - $skip = false; - if ( $wgUseMemCached ) { - $mcKey = wfMemcKey( 'proxy', 'ip', $ip ); - $mcValue = $wgMemc->get( $mcKey ); - if ( $mcValue ) { - $skip = true; - } - } + $mcKey = wfMemcKey( 'proxy', 'ip', $ip ); + $mcValue = $wgMemc->get( $mcKey ); + $skip = (bool)$mcValue; # Fork the processes if ( !$skip ) { @@ -165,9 +160,7 @@ function wfProxyCheck() { exec( "php $params &>/dev/null &" ); } # Set MemCached key - if ( $wgUseMemCached ) { - $wgMemc->set( $mcKey, 1, $wgProxyMemcExpiry ); - } + $wgMemc->set( $mcKey, 1, $wgProxyMemcExpiry ); } } -- 2.20.1