Add APC shared memory caching support, for those who desperately need it.
authorDomas Mituzas <midom@users.mediawiki.org>
Sun, 28 May 2006 16:44:16 +0000 (16:44 +0000)
committerDomas Mituzas <midom@users.mediawiki.org>
Sun, 28 May 2006 16:44:16 +0000 (16:44 +0000)
It doesn't mean that it is any faster than MySQL-based object cache %)

includes/BagOStuff.php
includes/ObjectCache.php

index 3e4fb7f..923882b 100644 (file)
@@ -480,6 +480,30 @@ class TurckBagOStuff extends BagOStuff {
        }
 }
 
+/**
+ * This is a wrapper for APC's shared memory functions
+ *
+ * @package MediaWiki
+ */
+
+class APCBagOStuff extends BagOStuff {
+       function get($key) {
+               $val = apc_fetch($key);
+               return (is_string($val))?$val:unserialize($val);
+       }
+       
+       function set($key, $value, $exptime=0) {
+               apc_store($key, $value, $exptime);
+               return true;
+       }
+       
+       function delete($key) {
+               apc_delete($key);
+               return true;
+       }
+}
+
+
 /**
  * This is a wrapper for eAccelerator's shared memory functions.
  *
index 223f5ff..fe7417d 100644 (file)
@@ -71,6 +71,9 @@ function &wfGetCache( $inputType ) {
                        if ( function_exists( 'eaccelerator_get' ) ) {
                                require_once( 'BagOStuff.php' );
                                $wgCaches[CACHE_ACCEL] = new eAccelBagOStuff;
+                       } elseif ( function_exists( 'apc_fetch') ) {
+                               require_once( 'BagOStuff.php' );
+                               $wgCaches[CACHE_ACCEL] = new APCBagOStuff;
                        } elseif ( function_exists( 'mmcache_get' ) ) {
                                require_once( 'BagOStuff.php' );
                                $wgCaches[CACHE_ACCEL] = new TurckBagOStuff;