eAccelerator caching support, patches from Jamie Bliss
authorBrion Vibber <brion@users.mediawiki.org>
Wed, 2 Mar 2005 01:54:05 +0000 (01:54 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Wed, 2 Mar 2005 01:54:05 +0000 (01:54 +0000)
config/index.php
includes/DefaultSettings.php
includes/ObjectCache.php
includes/Setup.php

index 7de46de..fe366ea 100644 (file)
@@ -273,8 +273,14 @@ if( $conf->zlib ) {
 $conf->turck = function_exists( 'mmcache_get' );
 if ( $conf->turck ) {
        print "<li><a href=\"http://turck-mmcache.sourceforge.net/\">Turck MMCache</a> installed</li>\n";
-} else {
-       print "<li><a href=\"http://turck-mmcache.sourceforge.net/\">Turck MMCache</a> not installed, " .
+}
+$conf->eaccel = function_exists( 'eaccelerator_get' );
+if ( $conf->eaccel ) {
+    $conf->turck = 'eaccelerator';
+    print "<li><a href=\"http://eaccelerator.sourceforge.net/\">eAccelerator</a> installed</li>\n";
+}
+if (!$conf->turck && !$conf->eaccel) {
+       print "<li>Neither <a href=\"http://turck-mmcache.sourceforge.net/\">Turck MMCache</a> nor <a href=\"http://eaccelerator.sourceforge.net/\">eAccelerator</a> are installed, " .
          "can't use object caching functions</li>\n";
 }
 
@@ -748,12 +754,19 @@ if( count( $errs ) ) {
                                echo "</li>";
                        }
                ?>
+               <?php 
+                       if ( $conf->eaccel ) {
+                               echo "<li>";
+                               aField( $conf, "Shm", "eAccelerator", "radio", "eaccel" );
+                               echo "</li>";
+                       }
+               ?>
                <li><?php aField( $conf, "Shm", "Memcached", "radio", "memcached" ); ?></li>
                <li><?php aField( $conf, "MCServers", "Memcached servers", "" ) ?></li>
                </ul>
        </dd>
        <dt>
-               Using a shared memory system such as Turck MMCache or Memcached will speed
+               Using a shared memory system such as Turck MMCache, 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-separted list. Only 
                use Turck shared memory if the wiki will be running on a single Apache server.
@@ -950,6 +963,7 @@ function writeLocalSettings( $conf ) {
                        $mcservers = var_export( $conf->MCServerArray, true );
                        break;
                case 'turck':
+               case 'eaccel':
                        $memcached = 'false';
                        $mcservers = 'array()';
                        $turck = '';
@@ -1071,6 +1085,7 @@ if ( \$wgCommandLineMode ) {
 \$wgUseMemCached = $memcached;
 \$wgMemCachedServers = $mcservers;
 {$turck}\$wgUseTurckShm = function_exists( 'mmcache_get' ) && php_sapi_name() == 'apache';
+{$turck}\$wgUseEAccelShm = function_exists( 'eaccelerator_get' ) && php_sapi_name() == 'apache';
 
 ## To enable image uploads, make sure the 'images' directory
 ## is writable, then uncomment this:
index 3bf5b54..4f8da74 100644 (file)
@@ -308,12 +308,26 @@ $wgLinkCacheMemcached = false; # Not fully tested
  * Turck MMCache shared memory
  * 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.
+ * memcached and eAccelerator, the preference order priorities being memcached first, 
+ * Turck MMCache second, and eAccelerator third.
  *
  * @global bool $wgUseTurckShm Enable or disabled Turck MMCache
  */
 $wgUseTurckShm      = false;
 
+/**
+ * eAccelerator shared memory
+ * You can use this for persistent caching where your wiki runs on a single 
+ * server. Enabled by default if eAccelerator is installed. Mutually exclusive with
+ * memcached and Turck MMCache, the preference order being memcached first, 
+ * Turck MMCache second, and eAccelerator third.
+ *
+ * Most of the code to support this is directly copied from the Turck code.
+ *
+ * @global bool $wgUseEAccelShm Enable or disabled eAccelerator
+ */
+$wgUseEAccelShm     = false;
+
 
 # Language settings
 #
index e1d13f8..b4bb22b 100644 (file)
@@ -454,4 +454,42 @@ class TurckBagOStuff extends BagOStuff {
                return true;
        }
 }      
+
+/**
+ * This is a wrapper for eAccelerator's shared memory functions. 
+ * 
+ * This is basically identical to the Turck MMCache version,
+ * mostly because eAccelerator is based on Turck MMCache.
+ *
+ * @package MediaWiki
+ */
+class eAccelBagOStuff extends BagOStuff {
+       function get($key) {
+               $val = eaccelerator_get( $key );
+               if ( is_string( $val ) ) {
+                       $val = unserialize( $val );
+               }
+               return $val;
+       }
+
+       function set($key, $value, $exptime=0) {
+               eaccelerator_put( $key, serialize( $value ), $exptime );
+               return true;
+       }
+       
+       function delete($key, $time=0) {
+               eaccelerator_rm( $key );
+               return true;
+       }
+
+       function lock($key, $waitTimeout = 0 ) {
+               eaccelerator_lock( $key );
+               return true;
+       }
+
+       function unlock($key) {
+               eaccelerator_unlock( $key );
+               return true;
+       }
+}      
 ?>
index b453130..2d48329 100644 (file)
@@ -145,6 +145,12 @@ if( $wgUseMemCached ) {
        require_once( 'ObjectCache.php' );
        $wgMemc = new TurckBagOStuff;
        $messageMemc = &$wgMemc;
+} elseif ( $wgUseEAccelShm ) {
+       # eAccelerator shared memory
+       #
+       require_once( 'ObjectCache.php' );
+       $wgMemc = new eAccelBagOStuff;
+       $messageMemc = &$wgMemc;
 } else {
        /**
         * No shared memory