Fixed bug with Turck MMCache wrapper, and made it the default where Turck is installe...
authorTim Starling <tstarling@users.mediawiki.org>
Sat, 23 Oct 2004 10:21:23 +0000 (10:21 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Sat, 23 Oct 2004 10:21:23 +0000 (10:21 +0000)
includes/DefaultSettings.php
includes/ObjectCache.php

index 825f5ec..758863a 100644 (file)
@@ -277,13 +277,13 @@ $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.
+ * You can use this for persistent caching where your wiki runs on a single 
+ * server. Enabled by default if Turck is installed. Mutually exclusive with
+ * memcached, memcached is used if both are specified.
  *
  * @global bool $wgUseTurckShm Enable or disabled Turck MMCache
  */
-$wgUseTurckShm      = false;
+$wgUseTurckShm      = function_exists( 'mmcache_get' );
 
 
 # Language settings
index ecbf731..7e182d8 100644 (file)
@@ -370,16 +370,31 @@ class MediaWikiBagOStuff extends SqlBagOStuff {
 }
 
 /**
- * @todo document
+ * This is a wrapper for Turck MMCache's shared memory functions. 
+ * 
+ * You can store objects with mmcache_put() and mmcache_get(), but Turck seems 
+ * to use a weird custom serializer that randomly segfaults. So we wrap calls 
+ * with serialize()/unserialize().
+ * 
+ * The thing I noticed about the Turck serialized data was that unlike ordinary
+ * serialize(), it contained the names of methods, and judging by the amount of 
+ * binary data, perhaps even the bytecode of the methods themselves. It may be 
+ * that Turck's serializer is faster, so a possible future extension would be 
+ * to use it for arrays but not for objects.
+ *
  * @package MediaWiki
  */
 class TurckBagOStuff extends BagOStuff {
        function get($key) {
-               return mmcache_get( $key );
+               $val = mmcache_get( $key );
+               if ( is_string( $val ) ) {
+                       $val = unserialize( $val );
+               }
+               return $val;
        }
 
        function set($key, $value, $exptime=0) {
-               mmcache_put( $key, $value, $exptime );
+               mmcache_put( $key, serialize( $value ), $exptime );
                return true;
        }