X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fobjectcache%2FMultiWriteBagOStuff.php;h=4120749682750e5441e9e9d46279007f42634820;hb=a004874bb08e72f7aa116aaa86293e3d5accb5c1;hp=e496ddd8ab497d45b1f66693924bee09f2400bd8;hpb=3e92dfbd2f0d12327aab3261b1b010eb06f932a9;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/objectcache/MultiWriteBagOStuff.php b/includes/objectcache/MultiWriteBagOStuff.php index e496ddd8ab..4120749682 100644 --- a/includes/objectcache/MultiWriteBagOStuff.php +++ b/includes/objectcache/MultiWriteBagOStuff.php @@ -22,8 +22,8 @@ */ /** - * A cache class that replicates all writes to multiple child caches. Reads - * are implemented by reading from the caches in the order they are given in + * A cache class that replicates all writes to multiple child caches. Reads + * are implemented by reading from the caches in the order they are given in * the configuration until a cache gives a positive result. * * @ingroup Cache @@ -61,9 +61,10 @@ class MultiWriteBagOStuff extends BagOStuff { /** * @param $key string + * @param $casToken[optional] mixed * @return bool|mixed */ - public function get( $key ) { + public function get( $key, &$casToken = null ) { foreach ( $this->caches as $cache ) { $value = $cache->get( $key ); if ( $value !== false ) { @@ -73,6 +74,17 @@ class MultiWriteBagOStuff extends BagOStuff { return false; } + /** + * @param $casToken mixed + * @param $key string + * @param $value mixed + * @param $exptime int + * @return bool + */ + public function cas( $casToken, $key, $value, $exptime = 0 ) { + throw new MWException( "CAS is not implemented in " . __CLASS__ ); + } + /** * @param $key string * @param $value mixed @@ -156,6 +168,17 @@ class MultiWriteBagOStuff extends BagOStuff { } } + /** + * @param $key string + * @param $callback closure Callback method to be executed + * @param $exptime int Either an interval in seconds or a unix timestamp for expiry + * @param $attempts int The amount of times to attempt a merge in case of failure + * @return bool success + */ + public function merge( $key, closure $callback, $exptime = 0, $attempts = 10 ) { + return $this->doWrite( 'merge', $key, $callback, $exptime ); + } + /** * @param $method string * @return bool