X-Git-Url: https://scripts.mit.edu/gitweb/autoinstallsdev/mediawiki.git/blobdiff_plain/19e297c21b10b1b8a3acad5e73fc71dcb35db44a..6932310fd58ebef145fa01eb76edf7150284d8ea:/includes/libs/objectcache/ReplicatedBagOStuff.php diff --git a/includes/libs/objectcache/ReplicatedBagOStuff.php b/includes/libs/objectcache/ReplicatedBagOStuff.php new file mode 100644 index 00000000..8239491f --- /dev/null +++ b/includes/libs/objectcache/ReplicatedBagOStuff.php @@ -0,0 +1,130 @@ + false ]; // redundant + $this->writeStore = ( $params['writeFactory'] instanceof BagOStuff ) + ? $params['writeFactory'] + : ObjectFactory::getObjectFromSpec( $opts + $params['writeFactory'] ); + $this->readStore = ( $params['readFactory'] instanceof BagOStuff ) + ? $params['readFactory'] + : ObjectFactory::getObjectFromSpec( $opts + $params['readFactory'] ); + $this->attrMap = $this->mergeFlagMaps( [ $this->readStore, $this->writeStore ] ); + } + + public function setDebug( $debug ) { + $this->writeStore->setDebug( $debug ); + $this->readStore->setDebug( $debug ); + } + + protected function doGet( $key, $flags = 0 ) { + return ( $flags & self::READ_LATEST ) + ? $this->writeStore->get( $key, $flags ) + : $this->readStore->get( $key, $flags ); + } + + public function getMulti( array $keys, $flags = 0 ) { + return ( $flags & self::READ_LATEST ) + ? $this->writeStore->getMulti( $keys, $flags ) + : $this->readStore->getMulti( $keys, $flags ); + } + + public function set( $key, $value, $exptime = 0, $flags = 0 ) { + return $this->writeStore->set( $key, $value, $exptime, $flags ); + } + + 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, $value = 1 ) { + return $this->writeStore->decr( $key, $value ); + } + + public function lock( $key, $timeout = 6, $expiry = 6, $rclass = '' ) { + return $this->writeStore->lock( $key, $timeout, $expiry, $rclass ); + } + + public function unlock( $key ) { + return $this->writeStore->unlock( $key ); + } + + public function merge( $key, callable $callback, $exptime = 0, $attempts = 10, $flags = 0 ) { + return $this->writeStore->merge( $key, $callback, $exptime, $attempts, $flags ); + } + + 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(); + } +}