* (bug 10181) Support the XCache object caching mechanism [patch from Kurt Radwanski]
authorRob Church <robchurch@users.mediawiki.org>
Fri, 8 Jun 2007 15:56:32 +0000 (15:56 +0000)
committerRob Church <robchurch@users.mediawiki.org>
Fri, 8 Jun 2007 15:56:32 +0000 (15:56 +0000)
* Minor tweak to installer form

RELEASE-NOTES
config/index.php
includes/AutoLoader.php
includes/BagOStuff.php
includes/ObjectCache.php

index 93eef9e..2c02dd3 100644 (file)
@@ -69,6 +69,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * (bug 8760) Allow wiki links in "protectexpiry" message
 * (bug 5908) Add "DEFAULTSORTKEY" and "DEFAULTCATEGORYSORT" aliases for
   "DEFAULTSORT" magic word
+* (bug 10181) Support the XCache object caching mechanism
 
 == Bugfixes since 1.10 ==
 
index 30d5cca..20c1581 100644 (file)
@@ -450,6 +450,10 @@ if ( $conf->turck ) {
        print "<li><a href=\"http://turck-mmcache.sourceforge.net/\">Turck MMCache</a> installed</li>\n";
 }
 
+$conf->xcache = function_exists( 'xcache_get' );
+if( $conf->xcache )
+       print "<li><a href=\"http://trac.lighttpd.net/xcache/\">XCache</a> installed</li>";
+
 $conf->apc = function_exists('apc_fetch');
 if ($conf->apc ) {
        print "<li><a href=\"http://www.php.net/apc\">APC</a> installed</li>";
@@ -461,10 +465,11 @@ if ( $conf->eaccel ) {
        print "<li><a href=\"http://eaccelerator.sourceforge.net/\">eAccelerator</a> installed</li>\n";
 }
 
-if( !$conf->turck && !$conf->eaccel && !$conf->apc ) {
+if( !( $conf->turck || $conf->eaccel || $conf->apc || $conf->xcache ) ) {
        echo( '<li>Couldn\'t find <a href="http://turck-mmcache.sourceforge.net">Turck MMCache</a>,
-               <a href="http://eaccelerator.sourceforge.net">eAccelerator</a>, or
-               <a href="http://www.php.net/apc">APC</a>. Object caching functions cannot be used.</li>' );
+               <a href="http://eaccelerator.sourceforge.net">eAccelerator</a>,
+               <a href="http://www.php.net/apc">APC</a> or <a href="http://trac.lighttpd.net/xcache/">XCache</a>.
+               Object caching functions cannot be used.</li>' );
 }
 
 $conf->diff3 = false;
@@ -1128,8 +1133,7 @@ if( count( $errs ) ) {
        <p class="config-desc">
                An admin can lock/delete pages, block users from editing, and do other maintenance tasks.<br />
                A new account will be added only when creating a new wiki database.
-       </p>
-       <p class="config-desc">
+               <br /><br />
                The password cannot be the same as the username.
        </p>
 
@@ -1144,6 +1148,11 @@ if( count( $errs ) ) {
                                aField( $conf, "Shm", "Turck MMCache", "radio", "turck" );
                                echo "</li>";
                        }
+                       if( $conf->xcache ) {
+                               echo( '<li>' );
+                               aField( $conf, 'Shm', 'XCache', 'radio', 'xcache' );
+                               echo( '</li>' );
+                       }
                        if ( $conf->apc ) {
                                echo "<li>";
                                aField( $conf, "Shm", "APC", "radio", "apc" );
@@ -1160,10 +1169,11 @@ if( count( $errs ) ) {
                <div style="clear:left"><?php aField( $conf, "MCServers", "Memcached servers:", "text" ) ?></div>
        </div>
        <p class="config-desc">
-               Using a shared memory system such as Turck MMCache, APC, eAccelerator, or Memcached 
-               will speed up MediaWiki significantly. Memcached is the best solution but needs to be
-               installed. Specify the server addresses and ports in a comma-separated list. Only
-               use Turck shared memory if the wiki will be running on a single Apache server.
+               An object caching system such as memcached will provide a significant performance boost,
+               but needs to be installed. Provide the server addresses and ports in a comma-separated list.
+               <br /><br />
+               MediaWiki can also detect and support eAccelerator, Turck MMCache, APC, and XCache, but
+               these should not be used if the wiki will be running on multiple application servers.
        </p>
 </div>
 
@@ -1395,6 +1405,7 @@ function writeLocalSettings( $conf ) {
                        $mcservers = var_export( $conf->MCServerArray, true );
                        break;
                case 'turck':
+               case 'xcache':
                case 'apc':
                case 'eaccel':
                        $cacheType = 'CACHE_ACCEL';
index 06e5b37..7f9a499 100644 (file)
@@ -22,6 +22,7 @@ function __autoload($className) {
                'TurckBagOStuff' => 'includes/BagOStuff.php',
                'APCBagOStuff' => 'includes/BagOStuff.php',
                'eAccelBagOStuff' => 'includes/BagOStuff.php',
+               'XCacheBagOStuff' => 'includes/BagOStuff.php',
                'DBABagOStuff' => 'includes/BagOStuff.php',
                'Block' => 'includes/Block.php',
                'HTMLFileCache' => 'includes/HTMLFileCache.php',
index 1174997..5cb14d9 100644 (file)
@@ -564,6 +564,52 @@ class eAccelBagOStuff extends BagOStuff {
        }
 }
 
+/**
+ * Wrapper for XCache object caching functions; identical interface
+ * to the APC wrapper
+ */
+class XCacheBagOStuff extends APCBagOStuff {
+
+       /**
+        * Get a value from the XCache object cache
+        *
+        * @param string $key Cache key
+        * @return mixed
+        */
+       public function get( $key ) {
+               $val = xcache_get( $key );
+               if( is_string( $val ) )
+                       $val = unserialize( $val );
+               return $val;
+       }
+       
+       /**
+        * Store a value in the XCache object cache
+        *
+        * @param string $key Cache key
+        * @param mixed $value Object to store
+        * @param int $expire Expiration time
+        * @return bool
+        */
+       public function set( $key, $value, $expire = 0 ) {
+               xcache_set( $key, serialize( $value ), $expire );
+               return true;
+       }
+       
+       /**
+        * Remove a value from the XCache object cache
+        *
+        * @param string $key Cache key
+        * @param int $time Not used in this implementation
+        * @return bool
+        */
+       public function delete( $key, $time = 0 ) {
+               xcache_unset( $key );
+               return true;
+       }
+       
+}
+
 /**
  * @todo document
  */
index a493a75..32ae5d3 100644 (file)
@@ -70,6 +70,8 @@ function &wfGetCache( $inputType ) {
                                $wgCaches[CACHE_ACCEL] = new eAccelBagOStuff;
                        } elseif ( function_exists( 'apc_fetch') ) {
                                $wgCaches[CACHE_ACCEL] = new APCBagOStuff;
+                       } elseif( function_exists( 'xcache_get' ) ) {
+                               $wgCaches[CACHE_ACCEL] = new XCacheBagOStuff();
                        } elseif ( function_exists( 'mmcache_get' ) ) {
                                $wgCaches[CACHE_ACCEL] = new TurckBagOStuff;
                        } else {