API: Fix documentation for ApiBase::require*OneParameter
[lhc/web/wiklou.git] / includes / objectcache / BagOStuff.php
index 99f73aa..56f1be2 100644 (file)
@@ -247,6 +247,23 @@ abstract class BagOStuff {
                return $res;
        }
 
+       /**
+        * Batch insertion
+        * @param array $data $key => $value assoc array
+        * @param int $exptime Either an interval in seconds or a unix timestamp for expiry
+        * @return bool success
+        * @since 1.24
+        */
+       public function setMulti( array $data, $exptime = 0 ) {
+               $res = true;
+               foreach ( $data as $key => $value ) {
+                       if ( !$this->set( $key, $value, $exptime ) ) {
+                               $res = false;
+                       }
+               }
+               return $res;
+       }
+
        /**
         * @param string $key
         * @param mixed $value
@@ -307,6 +324,23 @@ abstract class BagOStuff {
                return $this->incr( $key, - $value );
        }
 
+       /**
+        * Increase stored value of $key by $value while preserving its TTL
+        *
+        * This will create the key with value $init and TTL $ttl if not present
+        *
+        * @param string $key
+        * @param integer $ttl
+        * @param integer $value
+        * @param integer $init
+        * @return bool
+        * @since 1.24
+        */
+       public function incrWithInit( $key, $ttl, $value = 1, $init = 1 ) {
+               return $this->incr( $key, $value ) ||
+                       $this->add( $key, $init, $ttl ) || $this->incr( $key, $value );
+       }
+
        /**
         * Get the "last error" registered; clearLastError() should be called manually
         * @return int ERR_* constant for the "last error" registry