From: jenkins-bot Date: Tue, 5 May 2015 07:49:32 +0000 (+0000) Subject: Merge "Refactored ReplicatedBagOStuff to use generic factory methods" X-Git-Tag: 1.31.0-rc.0~11498 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/pie.php?a=commitdiff_plain;h=3e19b06deec72b3cca5b527e93f7023cfc4c2293;hp=b2faab0991a16b3102c8167bdb3147699f3b86fb;p=lhc%2Fweb%2Fwiklou.git Merge "Refactored ReplicatedBagOStuff to use generic factory methods" --- diff --git a/autoload.php b/autoload.php index 81ee8b1833..6c623a382b 100644 --- a/autoload.php +++ b/autoload.php @@ -993,7 +993,7 @@ $wgAutoloadLocalClasses = array( 'RenderAction' => __DIR__ . '/includes/actions/RenderAction.php', 'ReplacementArray' => __DIR__ . '/includes/libs/ReplacementArray.php', 'Replacer' => __DIR__ . '/includes/libs/replacers/Replacer.php', - 'ReplicatedBagOStuff' => __DIR__ . '/includes/objectcache/ReplicatedBagOStuff.php', + 'ReplicatedBagOStuff' => __DIR__ . '/includes/libs/objectcache/ReplicatedBagOStuff.php', 'RepoGroup' => __DIR__ . '/includes/filerepo/RepoGroup.php', 'RequestContext' => __DIR__ . '/includes/context/RequestContext.php', 'ResetUserTokens' => __DIR__ . '/maintenance/resetUserTokens.php', diff --git a/includes/libs/objectcache/ReplicatedBagOStuff.php b/includes/libs/objectcache/ReplicatedBagOStuff.php new file mode 100644 index 0000000000..99b03ed907 --- /dev/null +++ b/includes/libs/objectcache/ReplicatedBagOStuff.php @@ -0,0 +1,124 @@ +writeStore = ( $params['writeFactory'] instanceof BagOStuff ) + ? $params['writeFactory'] + : ObjectFactory::getObjectFromSpec( $params['writeFactory'] ); + $this->readStore = ( $params['readFactory'] instanceof BagOStuff ) + ? $params['readFactory'] + : ObjectFactory::getObjectFromSpec( $params['readFactory'] ); + } + + public function setDebug( $debug ) { + $this->writeStore->setDebug( $debug ); + $this->readStore->setDebug( $debug ); + } + + public function get( $key, &$casToken = null ) { + return $this->readStore->get( $key, $casToken ); + } + + public function getMulti( $keys ) { + return $this->readStore->getMulti( $keys ); + } + + public function set( $key, $value, $exptime = 0 ) { + return $this->writeStore->set( $key, $value, $exptime ); + } + + public function delete( $key ) { + return $this->writeStore->delete( $key ); + } + + public function add( $key, $value, $exptime = 0 ) { + return $this->writeStore->add( $key, $value, $exptime ); + } + + public function incr( $key, $value = 1 ) { + return $this->writeStore->incr( $key, $value ); + } + + public function decr( $key ) { + return $this->writeStore->decr( $key ); + } + + public function lock( $key, $timeout = 6, $expiry = 6 ) { + return $this->writeStore->lock( $key, $timeout, $expiry ); + } + + public function unlock( $key ) { + return $this->writeStore->unlock( $key ); + } + + public function merge( $key, $callback, $exptime = 0, $attempts = 10 ) { + return $this->writeStore->merge( $key, $callback, $exptime, $attempts ); + } + + public function getLastError() { + return ( $this->writeStore->getLastError() != self::ERR_NONE ) + ? $this->writeStore->getLastError() + : $this->readStore->getLastError(); + } + + public function clearLastError() { + $this->writeStore->clearLastError(); + $this->readStore->clearLastError(); + } +} diff --git a/includes/objectcache/ReplicatedBagOStuff.php b/includes/objectcache/ReplicatedBagOStuff.php deleted file mode 100644 index 34affc74b8..0000000000 --- a/includes/objectcache/ReplicatedBagOStuff.php +++ /dev/null @@ -1,122 +0,0 @@ -mCache = ( $params['masterCache'] instanceof BagOStuff ) - ? $params['masterCache'] - : ObjectCache::newFromParams( $params['masterCache'] ); - $this->sCache = ( $params['slaveCache'] instanceof BagOStuff ) - ? $params['slaveCache'] - : ObjectCache::newFromParams( $params['slaveCache'] ); - } - - public function setDebug( $debug ) { - $this->mCache->setDebug( $debug ); - $this->sCache->setDebug( $debug ); - } - - public function get( $key, &$casToken = null ) { - return $this->sCache->get( $key, $casToken ); - } - - public function getMulti( $keys ) { - return $this->sCache->getMulti( $keys ); - } - - public function set( $key, $value, $exptime = 0 ) { - return $this->mCache->set( $key, $value, $exptime ); - } - - public function delete( $key ) { - return $this->mCache->delete( $key ); - } - - public function add( $key, $value, $exptime = 0 ) { - return $this->mCache->add( $key, $value, $exptime ); - } - - public function incr( $key, $value = 1 ) { - return $this->mCache->incr( $key, $value ); - } - - public function decr( $key ) { - return $this->mCache->decr( $key ); - } - - public function lock( $key, $timeout = 6, $expiry = 6 ) { - return $this->mCache->lock( $key, $timeout, $expiry ); - } - - public function unlock( $key ) { - return $this->mCache->unlock( $key ); - } - - public function merge( $key, $callback, $exptime = 0, $attempts = 10 ) { - return $this->mCache->merge( $key, $callback, $exptime, $attempts ); - } - - public function getLastError() { - return ( $this->mCache->getLastError() != self::ERR_NONE ) - ? $this->mCache->getLastError() - : $this->sCache->getLastError(); - } - - public function clearLastError() { - $this->mCache->clearLastError(); - $this->sCache->clearLastError(); - } -}