8 if (!defined('MEDIAWIKI')) {
9 echo "Not a valid entry point\n";
15 * FakeMemCachedClient imitates the API of memcached-client v. 0.1.2.
16 * It acts as a memcached server with no RAM, that is, all objects are
17 * cleared the moment they are set. All set operations succeed and all
18 * get operations return null.
22 class FakeMemCachedClient
{
23 function add ($key, $val, $exp = 0) { return true; }
24 function decr ($key, $amt=1) { return null; }
25 function delete ($key, $time = 0) { return false; }
26 function disconnect_all () { }
27 function enable_compress ($enable) { }
28 function forget_dead_hosts () { }
29 function get ($key) { return null; }
30 function get_multi ($keys) { return array_pad(array(), count($keys), null); }
31 function incr ($key, $amt=1) { return null; }
32 function replace ($key, $value, $exp=0) { return false; }
33 function run_command ($sock, $cmd) { return null; }
34 function set ($key, $value, $exp=0){ return true; }
35 function set_compress_threshold ($thresh){ }
36 function set_debug ($dbg) { }
37 function set_servers ($list) { }
44 function &wfGetCache( $inputType ) {
45 global $wgCaches, $wgMemCachedServers, $wgMemCachedDebug;
48 if ( $inputType == CACHE_ANYTHING
) {
50 $type = key( $wgCaches );
51 if ( $type === false ||
$type === CACHE_NONE
) {
58 if ( $type == CACHE_MEMCACHED
) {
59 if ( !array_key_exists( CACHE_MEMCACHED
, $wgCaches ) ){
60 require_once( 'memcached-client.php' );
62 if (!class_exists("MemcachedClientforWiki")) {
63 class MemCachedClientforWiki
extends memcached
{
64 function _debugprint( $text ) {
65 wfDebug( "memcached: $text\n" );
70 $wgCaches[CACHE_DB
] = new MemCachedClientforWiki(
71 array('persistant' => false, 'compress_threshold' => 1500 ) );
72 $cache =& $wgCaches[CACHE_DB
];
73 $cache->set_servers( $wgMemCachedServers );
74 $cache->set_debug( $wgMemCachedDebug );
76 } elseif ( $type == CACHE_ACCEL
) {
77 if ( !array_key_exists( CACHE_ACCEL
, $wgCaches ) ) {
78 if ( function_exists( 'eaccelerator_get' ) ) {
79 require_once( 'BagOStuff.php' );
80 $wgCaches[CACHE_ACCEL
] = new eAccelBagOStuff
;
81 } elseif ( function_exists( 'mmcache_get' ) ) {
82 require_once( 'BagOStuff.php' );
83 $wgCaches[CACHE_ACCEL
] = new TurckBagOStuff
;
85 $wgCaches[CACHE_ACCEL
] = false;
88 if ( $wgCaches[CACHE_ACCEL
] !== false ) {
89 $cache =& $wgCaches[CACHE_ACCEL
];
93 if ( $type == CACHE_DB ||
( $inputType == CACHE_ANYTHING
&& $cache === false ) ) {
94 if ( !array_key_exists( CACHE_DB
, $wgCaches ) ) {
95 require_once( 'BagOStuff.php' );
96 $wgCaches[CACHE_DB
] = new MediaWikiBagOStuff('objectcache');
98 $cache =& $wgCaches[CACHE_DB
];
101 if ( $cache === false ) {
102 if ( !array_key_exists( CACHE_NONE
, $wgCaches ) ) {
103 $wgCaches[CACHE_NONE
] = new FakeMemCachedClient
;
105 $cache =& $wgCaches[CACHE_NONE
];
111 function &wfGetMainCache() {
112 global $wgMainCacheType;
113 $ret =& wfGetCache( $wgMainCacheType );
117 function &wfGetMessageCacheStorage() {
118 global $wgMessageCacheType;
119 $ret =& wfGetCache( $wgMessageCacheType );
123 function &wfGetParserCacheStorage() {
124 global $wgParserCacheType;
125 $ret =& wfGetCache( $wgParserCacheType );