📄 memcached.txt
字号:
memcached support for MediaWiki:From ca August 2003, MediaWiki has optional support for memcached, a"high-performance, distributed memory object caching system".For general information on it, see: http://www.danga.com/memcached/Memcached is likely more trouble than a small site will need, butfor a larger site with heavy load, like Wikipedia, it should helplighten the load on the database servers by caching data and objectsin memory.== Requirements ==* PHP must be compiled with --enable-sockets* libevent: http://www.monkey.org/~provos/libevent/ (as of 2003-08-11, 0.7a is current)* optionally, epoll-rt patch for Linux kernel: http://www.xmailserver.org/linux-patches/nio-improve.html* memcached: http://www.danga.com/memcached/download.bml (as of this writing, 1.1.9 is current) Memcached and libevent are under BSD-style licenses.The server should run on Linux and other Unix-like systems... youcan run multiple servers on one machine or on multiple machines ona network; storage can be distributed across multiple servers, andmultiple web servers can use the same cache cluster.********************* W A R N I N G ! ! ! ! ! ***********************Memcached has no security or authentication. Please ensure that yourserver is appropriately firewalled, and that the port(s) used formemcached servers are not publicly accessible. Otherwise, anyone onthe internet can put data into and read data from your cache.An attacker familiar with MediaWiki internals could use this to givethemselves developer access and delete all data from the wiki'sdatabase, as well as getting all users' password hashes and e-mailaddresses.********************* W A R N I N G ! ! ! ! ! ***********************== Setup ==If you want to start small, just run one memcached on your webserver: memcached -d -l 127.0.0.1 -p 11000 -m 64(to run in daemon mode, accessible only via loopback interface,on port 11000, using up to 64MB of memory)In your LocalSettings.php file, set: $wgUseMemCached = true; $wgMemCachedServers = array( "127.0.0.1:11000" );The wiki should then use memcached to cache various data. To usemultiple servers (physically separate boxes or multiple cacheson one machine on a large-memory x86 box), just add more itemsto the array. To increase the weight of a server (say, becauseit has twice the memory of the others and you want to spreadusage evenly), make its entry a subarray: $wgMemCachedServers = array( "127.0.0.1:11000", # one gig on this box array("192.168.0.1:11000", 2) # two gigs on the other box );== PHP client for memcached ==As of this writing, MediaWiki includes version 1.0.10 of the PHPmemcached client by Ryan Gilfether <hotrodder@rocketmail.com>.You'll find some documentation for it in the 'php-memcached'subdirectory under the present one.We intend to track updates, but if you want to check for the lastestreleased version, see http://www.danga.com/memcached/apis.bmlIf you don't set $wgUseMemCached, we still create a MemCacheClient,but requests to it are no-ops and we always fall through to thedatabase. If the cache daemon can't be contacted, it should alsodisable itself fairly smoothly.== 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 minutesLinkCache: 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() cleared by: LinkCache::clearBadLink() should be cleared on page deletion and renameMediaWiki namespace: key: $wgDBname:messages ex: wikidb:messages stores: an array where the keys are DB keys and the values are messages set in: wfMsg(), Article::editUpdates() both call wfLoadAllMessages() cleared by: nothingWatchlist: key: $wgDBname:watchlist:id:$userID ex: wikidb:watchlist:id:4635 stores: HTML string cleared by: nothing, expiry time $wgWLCacheTimeout (1 hour) note: emergency optimisation onlyIP blocks: key: $wgDBname:ipblocks ex: wikidb:ipblocks stores: array of arrays, for the BlockCache class cleared by: BlockCache:clear() ... more to come ...
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -