User:DanielRenfro/memcache

Memcached is a general-purpose distributed memory caching system. It works on a simple key-value system.

Running the memcached server
First, make sure there isn't already a memcached server running: % ps aux | grep memcached

by hand
You can start memcached by hand if you want to, but it's probably better to start it with the custom script we used. To start a daemon by hand: memcached -d -l 127.0.0.1 -p 11000 -m 128 memcached -d -l 127.0.0.1 -p 11001 -m 128

memcached help
In bold are the options we commonly use: memcached 1.1.12 -p     port number to listen on -l  interface to listen on, default is INDRR_ANY -d           run as a daemon -r           maximize core file limit -u assume identity of (only when run as root) -m     max memory to use for items in megabytes, default is 64 MB -M           return error on memory exhausted (rather than removing items) -c     max simultaneous connections, default is 1024 -k           lock down all paged memory -v           verbose (print errors/warnings while in event loop) -vv          very verbose (also print client commands/reponses) -h           print this help and exit -i           print memcached and libevent license -P    save PID in, only used with -d option

In Mediawiki
To use the memcached client from within MW we need to make use of the global $wgMemc variable.

background

 * at some point during the initialization of the wiki (per response), the Setup.php file is run, calling wfGetMainCache
 * wfGetMainCache looks to see what type of caching we want (set in $wgMainCacheType</tt>) and returns the appropriate object.
 * for CACHE_MEMCACHED, it returns an instance of MemCachedClientForWikis</tt>, and sets this to $wgMemc</tt>

Setup (in LocalSettings.php)
It is imperative that memcached be set up correctly in LocalSettings.php if we are going to make use of it.