/**
* 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
}
/**
- * @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;
}