From: Domas Mituzas Date: Sun, 28 May 2006 16:44:16 +0000 (+0000) Subject: Add APC shared memory caching support, for those who desperately need it. X-Git-Tag: 1.31.0-rc.0~56995 X-Git-Url: http://git.cyclocoop.org/%24image?a=commitdiff_plain;h=73bcdd7a9090b7fa3b5e869d9fd08149533bd6ec;p=lhc%2Fweb%2Fwiklou.git Add APC shared memory caching support, for those who desperately need it. It doesn't mean that it is any faster than MySQL-based object cache %) --- diff --git a/includes/BagOStuff.php b/includes/BagOStuff.php index 3e4fb7f560..923882b7d6 100644 --- a/includes/BagOStuff.php +++ b/includes/BagOStuff.php @@ -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. * diff --git a/includes/ObjectCache.php b/includes/ObjectCache.php index 223f5ffd5e..fe7417d2c1 100644 --- a/includes/ObjectCache.php +++ b/includes/ObjectCache.php @@ -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;