r31425 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r31424‎ | r31425 | r31426 >
Date:15:08, 1 March 2008
Author:ialex
Status:old
Tags:
Comment:
* Update docs/memcached.txt
* Kill call to $wgUseMemCached in includes/ProxyTools.php
Modified paths:
  • /trunk/phase3/docs/memcached.txt (modified) (history)
  • /trunk/phase3/includes/ProxyTools.php (modified) (history)

Diff [purge]

Index: trunk/phase3/docs/memcached.txt
@@ -78,53 +78,180 @@
7979 We intend to track updates, but if you want to check for the lastest
8080 released version, see http://www.danga.com/memcached/apis.bml
8181
82 -If you don't set $wgUseMemCached, we still create a MemCacheClient,
 82+MediaWiki use three object for memcached:
 83+* $wgMemc, controlled by $wgMainCacheType
 84+* $parserMemc, controlled by $wgParserCacheType
 85+* $messageMemc, controlled by $wgMessageCacheType
 86+If you set CACHE_NONE to one of the three control variable, (default
 87+value for $wgMainCacheType), MediaWiki still create a MemCacheClient,
8388 but requests to it are no-ops and we always fall through to the
8489 database. If the cache daemon can't be contacted, it should also
8590 disable itself fairly smoothly.
8691
 92+By default, $wgMemc is used but when it is $parserMemc or $messageMemc
 93+this is mentionned below.
 94+
8795 == Keys used ==
8896
89 -User:
90 - key: $wgDBname:user:id:$sId
91 - ex: wikidb:user:id:51
92 - stores: instance of class User
93 - set in: User::loadFromSession()
94 - cleared by: User::saveSettings(), UserTalkUpdate::doUpdate()
95 -
96 -Newtalk:
97 - key: $wgDBname:newtalk:ip:$ip
98 - ex: wikidb:newtalk:ip:123.45.67.89
99 - stores: integer, 0 or 1
100 - set in: User::loadFromDatabase()
101 - cleared by: User::saveSettings() # ?
102 - expiry set to 30 minutes
 97+Ajax Search:
 98+ key: $wgDBname:ajaxsearch:md5( $search )
 99+ ex: wikidb:ajaxsearch:
 100+ stores: array with the result of research of a given text
 101+ cleared by: nothing
 102+ expiry: 30 minutes
103103
104 -LinkCache:
 104+Date Formatter:
 105+ key: $wgDBname:dateformatter
 106+ ex: wikidb:dateformatter
 107+ stores: a single instance of the DateFormatter class
 108+ cleared by: nothing
 109+ expiry: one hour
 110+
 111+Difference Engine:
 112+ key: $wgDBname:diff:version:{MW_DIFF_VERSION}:oldid:$old:newid:$new
 113+ ex: wikidb:diff:version:1.11a:oldid:1:newid:2
 114+ stores: body of a difference
 115+ cleared by: nothing
 116+ expiry: one week
 117+
 118+Interwiki:
 119+ key: $wgDBname:interwiki:$prefix
 120+ ex: wikidb:interwiki:w
 121+ stores: object from the interwiki table of the database
 122+ expiry: $wgInterwikiExpiry
 123+ cleared by: nothing
 124+
 125+Lag time of the databases:
 126+ key: $wgDBname:lag_times
 127+ ex: wikidb:lag_times
 128+ stores: array mapping the database id to its lag time
 129+ expriy: 5 secondes
 130+ cleared by: nothing
 131+
 132+Link Cache:
 133+ controlled by: $wgLinkCacheMemcached
105134 key: $wgDBname:lc:title:$title
106135 ex: wikidb:lc:title:Wikipedia:Welcome,_Newcomers!
107136 stores: cur_id of page, or 0 if page does not exist
108137 set in: LinkCache::addLink()
 138+ expriry: one day
109139 cleared by: LinkCache::clearBadLink()
110140 should be cleared on page deletion and rename
111 -MediaWiki namespace:
112 - key: $wgDBname:messages
113 - ex: wikidb:messages
 141+
 142+Localisation:
 143+ key: $wgDBname:localisation:$lang
 144+ ex: wikidb:localisation:de
 145+ stores: array of localisation settings
 146+ set in: Language::loadLocalisation()
 147+ expiry: none
 148+ cleared by: Language::loadLocalisation()
 149+
 150+Message Cache:
 151+ stored in: $parserMemc
 152+ key: $wgDBname:messages, $wgDBname:messages-hash, $wgDBname:messages-status
 153+ ex: wikidb:messages, wikidb:messages-hash, wikidb:messages-status
114154 stores: an array where the keys are DB keys and the values are messages
115155 set in: wfMsg(), Article::editUpdates() both call wfLoadAllMessages()
 156+ expriy: $wgMsgCacheExpiry
116157 cleared by: nothing
117158
118 -Watchlist:
119 - key: $wgDBname:watchlist:id:$userID
120 - ex: wikidb:watchlist:id:4635
121 - stores: HTML string
122 - cleared by: nothing, expiry time $wgWLCacheTimeout (1 hour)
123 - note: emergency optimisation only
 159+Newtalk:
 160+ key: $wgDBname:newtalk:ip:$ip
 161+ ex: wikidb:newtalk:ip:123.45.67.89
 162+ stores: integer, 0 or 1
 163+ set in: User::loadFromDatabase()
 164+ cleared by: User::saveSettings() # ?
 165+ expiry: 30 minutes
124166
125 -IP blocks:
126 - key: $wgDBname:ipblocks
127 - ex: wikidb:ipblocks
128 - stores: array of arrays, for the BlockCache class
129 - cleared by: BlockCache:clear()
 167+Parser Cache:
 168+ stored in: $parserMemc
 169+ controlled by: $wgEnableParserCache
 170+ key: $wgDBname:pcache:idhash:$pageid-$renderkey!$hash$edit
 171+ $pageid: id of the page
 172+ $renderkey: 1 if action=render, 0 otherwise
 173+ $hash: hash of user options, see User::getPageRenderingHash()
 174+ $edit: '!edit=0' if the user can't edit the page, '' otherwise
 175+ ex: wikidb:pcache:idhash:1-0!1!0!!en!2
 176+ stores: ParserOutput object
 177+ modified by: Article::editUpdates()
 178+ expriy: $wgParserCacheExpireTime or one hour if it contains specific magic
 179+ words
 180+
 181+Ping limiter:
 182+ controlled by: $wgRateLimits
 183+ key: $wgDBname:limiter:action:$action:ip:$ip,
 184+ $wgDBname:limiter:action:$action:user:$id,
 185+ mediawiki:limiter:action:$action:ip:$ip and
 186+ mediawiki:limiter:action:$action:subnet:$sub
 187+ ex: wikidb:limiter:action:edit:ip:123.45.67.89,
 188+ wikidb:limiter:action:edit:user:1012
 189+ mediawiki:limiter:action:edit:ip:123.45.67.89 and
 190+ mediawiki:limiter:action:$action:subnet:123.45.67
 191+ stores: number of action made by user/ip/subnet
 192+ cleared by: nothing
 193+ expiry: expiry set for the action and group in $wgRateLimits
 194+
 195+
 196+Proxy Check: (deprecated)
 197+ key: $wgDBname:proxy:ip:$ip
 198+ ex: wikidb:proxy:ip:123.45.67.89
 199+ stores: 1 if the ip is a proxy
 200+ cleared by: nothing
 201+ expiry: $wgProxyMemcExpiry
 202+
 203+Revision text:
 204+ key: $wgDBname:revisiontext:textid:$id
 205+ ex: wikidb:revisiontext:textid:1012
 206+ stores: text of a revision
 207+ cleared by: nothing
 208+ expriry: $wgRevisionCacheExpiry
 209+
 210+Sessions:
 211+ controlled by: $wgSessionsInMemcached
 212+ key: $wgBDname:session:$id
 213+ ex: wikidb:session:38d7c5b8d3bfc51egf40c69bc40f8be3
 214+ stores: $SESSION, useful when using a multi-sever wiki
 215+ expriy: one hour
 216+ cleared by: session_destroy()
 217+
 218+Sidebar:
 219+ stored in: $parserMemc
 220+ controlled by: $wgEnableSidebarCache
 221+ key: $wgDBname:sidebar
 222+ ex: wikidb:sidebar
 223+ stores: the html output of the sidebar
 224+ expriy: $wgSidebarCacheExpiry
 225+ cleared by: MessageCache::replace()
 226+
 227+Special:Allpages:
 228+ key: $wgDBname:allpages:ns:$ns
 229+ ex: wikidb:allpages:ns:0
 230+ stores: array of pages in a namespace
 231+ expiry: one hour
 232+ cleared by: nothing
 233+
 234+Special:Recentchanges (feed):
 235+ stored in: $messageMemc
 236+ key: $wgDBname:rcfeed:$format:limit:$imit:minor:$hideminor and
 237+ rcfeed:$format:timestamp
 238+ ex: wikidb:rcfeed:rss:limit:50:minor:0 and rcfeed:rss:timestamp
 239+ stores: xml output of feed
 240+ expiry: one day
 241+ clear by: calling Special:Recentchanges?action=purge
 242+
 243+Statistics:
 244+ controlled by: $wgStatsMethod
 245+ key: $wgDBname:stats:$key
 246+ ex: wikibd:stats:request_with_session
 247+ stores: counter for statistics (see maintenance/stats.php script)
 248+ expiry: none (?)
 249+ cleared by: maintenance/clear_stats.php script
 250+
 251+User:
 252+ key: $wgDBname:user:id:$sId
 253+ ex: wikidb:user:id:51
 254+ stores: instance of class User
 255+ set in: User::saveToCache()
 256+ cleared by: User::saveSettings(), User::clearSharedCache()
130257
131258 ... more to come ...
\ No newline at end of file
Index: trunk/phase3/includes/ProxyTools.php
@@ -130,7 +130,7 @@
131131 */
132132 function wfProxyCheck() {
133133 global $wgBlockOpenProxies, $wgProxyPorts, $wgProxyScriptPath;
134 - global $wgUseMemCached, $wgMemc, $wgProxyMemcExpiry;
 134+ global $wgMemc, $wgProxyMemcExpiry;
135135 global $wgProxyKey;
136136
137137 if ( !$wgBlockOpenProxies ) {
@@ -140,14 +140,9 @@
141141 $ip = wfGetIP();
142142
143143 # Get MemCached key
144 - $skip = false;
145 - if ( $wgUseMemCached ) {
146 - $mcKey = wfMemcKey( 'proxy', 'ip', $ip );
147 - $mcValue = $wgMemc->get( $mcKey );
148 - if ( $mcValue ) {
149 - $skip = true;
150 - }
151 - }
 144+ $mcKey = wfMemcKey( 'proxy', 'ip', $ip );
 145+ $mcValue = $wgMemc->get( $mcKey );
 146+ $skip = (bool)$mcValue;
152147
153148 # Fork the processes
154149 if ( !$skip ) {
@@ -165,9 +160,7 @@
166161 exec( "php $params &>/dev/null &" );
167162 }
168163 # Set MemCached key
169 - if ( $wgUseMemCached ) {
170 - $wgMemc->set( $mcKey, 1, $wgProxyMemcExpiry );
171 - }
 164+ $wgMemc->set( $mcKey, 1, $wgProxyMemcExpiry );
172165 }
173166 }
174167

Status & tagging log