X-Git-Url: https://scripts.mit.edu/gitweb/autoinstallsdev/mediawiki.git/blobdiff_plain/19e297c21b10b1b8a3acad5e73fc71dcb35db44a..6932310fd58ebef145fa01eb76edf7150284d8ea:/includes/libs/objectcache/CachedBagOStuff.php diff --git a/includes/libs/objectcache/CachedBagOStuff.php b/includes/libs/objectcache/CachedBagOStuff.php new file mode 100644 index 00000000..c85a82ea --- /dev/null +++ b/includes/libs/objectcache/CachedBagOStuff.php @@ -0,0 +1,121 @@ +backend = $backend; + $this->attrMap = $backend->attrMap; + } + + protected function doGet( $key, $flags = 0 ) { + $ret = parent::doGet( $key, $flags ); + if ( $ret === false && !$this->hasKey( $key ) ) { + $ret = $this->backend->doGet( $key, $flags ); + $this->set( $key, $ret, 0, self::WRITE_CACHE_ONLY ); + } + return $ret; + } + + public function set( $key, $value, $exptime = 0, $flags = 0 ) { + parent::set( $key, $value, $exptime, $flags ); + if ( !( $flags & self::WRITE_CACHE_ONLY ) ) { + $this->backend->set( $key, $value, $exptime, $flags & ~self::WRITE_CACHE_ONLY ); + } + return true; + } + + public function delete( $key, $flags = 0 ) { + unset( $this->bag[$key] ); + if ( !( $flags & self::WRITE_CACHE_ONLY ) ) { + $this->backend->delete( $key ); + } + + return true; + } + + public function setDebug( $bool ) { + parent::setDebug( $bool ); + $this->backend->setDebug( $bool ); + } + + public function deleteObjectsExpiringBefore( $date, $progressCallback = false ) { + parent::deleteObjectsExpiringBefore( $date, $progressCallback ); + return $this->backend->deleteObjectsExpiringBefore( $date, $progressCallback ); + } + + public function makeKey() { + return call_user_func_array( [ $this->backend, __FUNCTION__ ], func_get_args() ); + } + + public function makeGlobalKey() { + return call_user_func_array( [ $this->backend, __FUNCTION__ ], func_get_args() ); + } + + // These just call the backend (tested elsewhere) + // @codeCoverageIgnoreStart + + public function lock( $key, $timeout = 6, $expiry = 6, $rclass = '' ) { + return $this->backend->lock( $key, $timeout, $expiry, $rclass ); + } + + public function unlock( $key ) { + return $this->backend->unlock( $key ); + } + + public function getLastError() { + return $this->backend->getLastError(); + } + + public function clearLastError() { + return $this->backend->clearLastError(); + } + + public function modifySimpleRelayEvent( array $event ) { + return $this->backend->modifySimpleRelayEvent( $event ); + } + + // @codeCoverageIgnoreEnd +}