*/
$wgUseLocalMessageCache = false;
+/**
+ * Make LanguageConverter use a different cache type.
+ * Possible values are false (none), 'main' ($wgMemc), and 'apc'.
+ * @since 1.20
+ */
+$wgLanguageConverterCacheType = 'main';
+
/**
* Defines format of local cache
* true - Serialized object
* );
*/
$wgParserTestRemote = false;
-
+
/**
* Allow running of javascript test suites via [[Special:JavaScriptTest]] (such as QUnit).
*/
if ( $this->mTablesLoaded ) {
return;
}
- global $wgMemc;
+
wfProfileIn( __METHOD__ );
$this->mTablesLoaded = true;
$this->mTables = false;
if ( $fromCache ) {
wfProfileIn( __METHOD__ . '-cache' );
- $this->mTables = $wgMemc->get( $this->mCacheKey );
+ $this->mTables = $this->cacheFetch( $this->mCacheKey );
wfProfileOut( __METHOD__ . '-cache' );
}
if ( !$this->mTables
$this->postLoadTables();
$this->mTables[self::CACHE_VERSION_KEY] = true;
- $wgMemc->set( $this->mCacheKey, $this->mTables, 43200 );
+ $this->cacheStore( $this->mCacheKey, $this->mTables, 43200 );
wfProfileOut( __METHOD__ . '-recache' );
}
wfProfileOut( __METHOD__ );
}
+ /**
+ * Read an object from the cache
+ * @param $key string
+ * @return mixed
+ */
+ protected function cacheFetch( $key ) {
+ global $wgLanguageConverterCacheType, $wgMemc;
+
+ if ( $wgLanguageConverterCacheType === 'apc' ) {
+ return apc_fetch( $key );
+ } elseif ( $wgLanguageConverterCacheType === 'main' ) {
+ return $wgMemc->get( $key );
+ }
+
+ return false; // disabled
+ }
+
+ /**
+ * Store an object into the cache
+ * @param $key string
+ * @param $val mixed
+ * @param $ttl integer Seconds to live
+ * @return bool Success
+ */
+ protected function cacheStore( $key, $val, $ttl ) {
+ global $wgLanguageConverterCacheType, $wgMemc;
+
+ if ( $wgLanguageConverterCacheType === 'apc' ) {
+ return apc_store( $key, $val, $ttl );
+ } elseif ( $wgLanguageConverterCacheType === 'main' ) {
+ return $wgMemc->set( $key, $val, $ttl );
+ }
+
+ return true; // disabled
+ }
+
/**
* Hook for post processing after conversion tables are loaded.
*/