Merge "Add mediawiki.org to default $wgNoFollowDomainExceptions"
[lhc/web/wiklou.git] / includes / objectcache / MultiWriteBagOStuff.php
index 2f37c23..e550c0d 100644 (file)
@@ -43,7 +43,7 @@ class MultiWriteBagOStuff extends BagOStuff {
         */
        public function __construct( $params ) {
                if ( !isset( $params['caches'] ) ) {
-                       throw new MWException( __METHOD__.': the caches parameter is required' );
+                       throw new MWException( __METHOD__ . ': the caches parameter is required' );
                }
 
                $this->caches = array();
@@ -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 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
+        */
+       public function merge( $key, closure $callback, $exptime = 0, $attempts = 10 ) {
+               return $this->doWrite( 'merge', $key, $callback, $exptime );
+       }
+
        /**
         * @param $method string
         * @return bool