8 if (!defined('MEDIAWIKI')) die( "Not a valid entry point\n");
12 * FakeMemCachedClient imitates the API of memcached-client v. 0.1.2.
13 * It acts as a memcached server with no RAM, that is, all objects are
14 * cleared the moment they are set. All set operations succeed and all
15 * get operations return null.
19 class FakeMemCachedClient
{
20 function add ($key, $val, $exp = 0) { return true; }
21 function decr ($key, $amt=1) { return null; }
22 function delete ($key, $time = 0) { return false; }
23 function disconnect_all () { }
24 function enable_compress ($enable) { }
25 function forget_dead_hosts () { }
26 function get ($key) { return null; }
27 function get_multi ($keys) { return array_pad(array(), count($keys), null); }
28 function incr ($key, $amt=1) { return null; }
29 function replace ($key, $value, $exp=0) { return false; }
30 function run_command ($sock, $cmd) { return null; }
31 function set ($key, $value, $exp=0){ return true; }
32 function set_compress_threshold ($thresh){ }
33 function set_debug ($dbg) { }
34 function set_servers ($list) { }
41 function &wfGetCache( $inputType ) {
42 global $wgCaches, $wgMemCachedServers, $wgMemCachedDebug;
45 if ( $inputType == CACHE_ANYTHING
) {
47 $type = key( $wgCaches );
48 if ( $type === false ||
$type === CACHE_NONE
) {
55 if ( $type == CACHE_MEMCACHED
) {
56 if ( !array_key_exists( CACHE_MEMCACHED
, $wgCaches ) ){
57 require_once( 'memcached-client.php' );
59 if (!class_exists("MemcachedClientforWiki")) {
60 class MemCachedClientforWiki
extends memcached
{
61 function _debugprint( $text ) {
62 wfDebug( "memcached: $text\n" );
67 $wgCaches[CACHE_DB
] = new MemCachedClientforWiki(
68 array('persistant' => false, 'compress_threshold' => 1500 ) );
69 $cache =& $wgCaches[CACHE_DB
];
70 $cache->set_servers( $wgMemCachedServers );
71 $cache->set_debug( $wgMemCachedDebug );
73 } elseif ( $type == CACHE_ACCEL
) {
74 if ( !array_key_exists( CACHE_ACCEL
, $wgCaches ) ) {
75 if ( function_exists( 'eaccelerator_get' ) ) {
76 require_once( 'BagOStuff.php' );
77 $wgCaches[CACHE_ACCEL
] = new eAccelBagOStuff
;
78 } elseif ( function_exists( 'mmcache_get' ) ) {
79 require_once( 'BagOStuff.php' );
80 $wgCaches[CACHE_ACCEL
] = new TurckBagOStuff
;
82 $wgCaches[CACHE_ACCEL
] = false;
85 if ( $wgCaches[CACHE_ACCEL
] !== false ) {
86 $cache =& $wgCaches[CACHE_ACCEL
];
90 if ( $type == CACHE_DB ||
( $inputType == CACHE_ANYTHING
&& $cache === false ) ) {
91 if ( !array_key_exists( CACHE_DB
, $wgCaches ) ) {
92 require_once( 'BagOStuff.php' );
93 $wgCaches[CACHE_DB
] = new MediaWikiBagOStuff('objectcache');
95 $cache =& $wgCaches[CACHE_DB
];
98 if ( $cache === false ) {
99 if ( !array_key_exists( CACHE_NONE
, $wgCaches ) ) {
100 $wgCaches[CACHE_NONE
] = new FakeMemCachedClient
;
102 $cache =& $wgCaches[CACHE_NONE
];
108 function &wfGetMainCache() {
109 global $wgMainCacheType;
110 $ret =& wfGetCache( $wgMainCacheType );
114 function &wfGetMessageCacheStorage() {
115 global $wgMessageCacheType;
116 $ret =& wfGetCache( $wgMessageCacheType );
120 function &wfGetParserCacheStorage() {
121 global $wgParserCacheType;
122 $ret =& wfGetCache( $wgParserCacheType );