diff options
Diffstat (limited to 'includes/objectcache/MultiWriteBagOStuff.php')
-rw-r--r-- | includes/objectcache/MultiWriteBagOStuff.php | 83 |
1 files changed, 42 insertions, 41 deletions
diff --git a/includes/objectcache/MultiWriteBagOStuff.php b/includes/objectcache/MultiWriteBagOStuff.php index e550c0d0..6a691379 100644 --- a/includes/objectcache/MultiWriteBagOStuff.php +++ b/includes/objectcache/MultiWriteBagOStuff.php @@ -29,7 +29,8 @@ * @ingroup Cache */ class MultiWriteBagOStuff extends BagOStuff { - var $caches; + /** @var array BagOStuff[] */ + protected $caches; /** * Constructor. Parameters are: @@ -38,7 +39,7 @@ class MultiWriteBagOStuff extends BagOStuff { * structures, in the style required by $wgObjectCaches. See * the documentation of $wgObjectCaches for more detail. * - * @param $params array + * @param array $params * @throws MWException */ public function __construct( $params ) { @@ -53,15 +54,15 @@ class MultiWriteBagOStuff extends BagOStuff { } /** - * @param $debug bool + * @param bool $debug */ public function setDebug( $debug ) { $this->doWrite( 'setDebug', $debug ); } /** - * @param $key string - * @param $casToken[optional] mixed + * @param string $key + * @param mixed $casToken [optional] * @return bool|mixed */ public function get( $key, &$casToken = null ) { @@ -75,10 +76,10 @@ class MultiWriteBagOStuff extends BagOStuff { } /** - * @param $casToken mixed - * @param $key string - * @param $value mixed - * @param $exptime int + * @param mixed $casToken + * @param string $key + * @param mixed $value + * @param mixed $exptime * @return bool */ public function cas( $casToken, $key, $value, $exptime = 0 ) { @@ -86,9 +87,9 @@ class MultiWriteBagOStuff extends BagOStuff { } /** - * @param $key string - * @param $value mixed - * @param $exptime int + * @param string $key + * @param mixed $value + * @param int $exptime * @return bool */ public function set( $key, $value, $exptime = 0 ) { @@ -96,8 +97,8 @@ class MultiWriteBagOStuff extends BagOStuff { } /** - * @param $key string - * @param $time int + * @param string $key + * @param int $time * @return bool */ public function delete( $key, $time = 0 ) { @@ -105,9 +106,9 @@ class MultiWriteBagOStuff extends BagOStuff { } /** - * @param $key string - * @param $value mixed - * @param $exptime int + * @param string $key + * @param mixed $value + * @param int $exptime * @return bool */ public function add( $key, $value, $exptime = 0 ) { @@ -115,18 +116,8 @@ class MultiWriteBagOStuff extends BagOStuff { } /** - * @param $key string - * @param $value mixed - * @param $exptime int - * @return bool - */ - public function replace( $key, $value, $exptime = 0 ) { - return $this->doWrite( 'replace', $key, $value, $exptime ); - } - - /** - * @param $key string - * @param $value int + * @param string $key + * @param int $value * @return bool|null */ public function incr( $key, $value = 1 ) { @@ -134,8 +125,8 @@ class MultiWriteBagOStuff extends BagOStuff { } /** - * @param $key string - * @param $value int + * @param string $key + * @param int $value * @return bool */ public function decr( $key, $value = 1 ) { @@ -143,8 +134,8 @@ class MultiWriteBagOStuff extends BagOStuff { } /** - * @param $key string - * @param $timeout int + * @param string $key + * @param int $timeout * @return bool */ public function lock( $key, $timeout = 0 ) { @@ -157,7 +148,7 @@ class MultiWriteBagOStuff extends BagOStuff { } /** - * @param $key string + * @param string $key * @return bool */ public function unlock( $key ) { @@ -169,18 +160,28 @@ class MultiWriteBagOStuff extends BagOStuff { } /** - * @param $key string - * @param $callback closure Callback method to be executed + * @param string $key + * @param Closure $callback Callback method to be executed * @param int $exptime Either an interval in seconds or a unix timestamp for expiry * @param int $attempts The amount of times to attempt a merge in case of failure - * @return bool success + * @return bool Success */ - public function merge( $key, closure $callback, $exptime = 0, $attempts = 10 ) { + public function merge( $key, Closure $callback, $exptime = 0, $attempts = 10 ) { return $this->doWrite( 'merge', $key, $callback, $exptime ); } + public function getLastError() { + return isset( $this->caches[0] ) ? $this->caches[0]->getLastError() : self::ERR_NONE; + } + + public function clearLastError() { + if ( isset( $this->caches[0] ) ) { + $this->caches[0]->clearLastError(); + } + } + /** - * @param $method string + * @param string $method * @return bool */ protected function doWrite( $method /*, ... */ ) { @@ -200,8 +201,8 @@ class MultiWriteBagOStuff extends BagOStuff { * Delete objects expiring before a certain date. * * Succeed if any of the child caches succeed. - * @param $date string - * @param $progressCallback bool|callback + * @param string $date + * @param bool|callable $progressCallback * @return bool */ public function deleteObjectsExpiringBefore( $date, $progressCallback = false ) { |