$wgSessionsInMemcached = false;
$wgLinkCacheMemcached = false; # Not fully tested
+# Turck MMCache shared memory
+# You can use this for persistent caching where your wiki runs on a small number of
+# servers. Mutually exclusive with memcached. MMCache must be installed.
+$wgUseTurckShm = false;
+
# Language settings
#
var $debugmode;
function BagOStuff() {
- set_debug( false );
+ $this->set_debug( false );
}
function set_debug($bool) {
return false;
}
+ function lock($key, $timeout = 0) {
+ /* stub */
+ return true;
+ }
+
+ function unlock($key) {
+ /* stub */
+ return true;
+ }
+
/* *** Emulated functions *** */
/* Better performance can likely be got with custom written versions */
function get_multi($keys) {
}
function incr($key, $value=1) {
+ if ( !$this->lock($key) ) {
+ return false;
+ }
$value = intval($value);
if($value < 0) $value = 0;
+
+ $n = false;
if( ($n = $this->get($key)) !== false ) {
- $this->set($key, $n+$value); // exptime?
- return $n+$value;
- } else {
- return false;
+ $n += $value;
+ $this->set($key, $n); // exptime?
}
+ $this->unlock($key);
+ return $n;
}
function decr($key, $value=1) {
+ if ( !$this->lock($key) ) {
+ return false;
+ }
$value = intval($value);
if($value < 0) $value = 0;
+
+ $m = false;
if( ($n = $this->get($key)) !== false ) {
$m = $n - $value;
if($m < 0) $m = 0;
$this->set($key, $m); // exptime?
- return $m;
- } else {
- return false;
}
+ $this->unlock($key);
+ return $m;
}
function _debug($text) {
}
}
+class TurckBagOStuff extends BagOStuff {
+ function get($key) {
+ return mmcache_get( $key );
+ }
+
+ function set($key, $value, $exptime=0) {
+ mmcache_put( $key, $value, $exptime );
+ return true;
+ }
+
+ function delete($key, $time=0) {
+ mmcache_rm( $key );
+ return true;
+ }
+
+ function lock($key, $waitTimeout = 0 ) {
+ mmcache_lock( $key );
+ return true;
+ }
+
+ function unlock($key) {
+ mmcache_unlock( $key );
+ return true;
+ }
+}
?>
$wgMemc->set_servers( $wgMemCachedServers );
$wgMemc->set_debug( $wgMemCachedDebug );
+ $messageMemc = &$wgMemc;
+} elseif ( $wgUseTurckShm ) {
+ # Turck shared memory
+ #
+ require_once( 'ObjectCache.php' );
+ $wgMemc = new TurckBagOStuff;
$messageMemc = &$wgMemc;
} else {
+ # No shared memory
+ #
class FakeMemCachedClient {
function add ($key, $val, $exp = 0) { return true; }
function decr ($key, $amt=1) { return null; }