objectcache: improve BagOStuff arithmetic method signatures
[lhc/web/wiklou.git] / includes / libs / objectcache / HashBagOStuff.php
index 83c8004..6d0940b 100644 (file)
@@ -81,7 +81,7 @@ class HashBagOStuff extends MediumSpecificBagOStuff {
                unset( $this->bag[$key] );
                $this->bag[$key] = [
                        self::KEY_VAL => $value,
-                       self::KEY_EXP => $this->convertToExpiry( $exptime ),
+                       self::KEY_EXP => $this->getExpirationAsTimestamp( $exptime ),
                        self::KEY_CAS => $this->token . ':' . ++self::$casCounter
                ];
 
@@ -94,7 +94,7 @@ class HashBagOStuff extends MediumSpecificBagOStuff {
                return true;
        }
 
-       public function add( $key, $value, $exptime = 0, $flags = 0 ) {
+       protected function doAdd( $key, $value, $exptime = 0, $flags = 0 ) {
                if ( $this->hasKey( $key ) && !$this->expire( $key ) ) {
                        return false; // key already set
                }
@@ -108,10 +108,10 @@ class HashBagOStuff extends MediumSpecificBagOStuff {
                return true;
        }
 
-       public function incr( $key, $value = 1 ) {
+       public function incr( $key, $value = 1, $flags = 0 ) {
                $n = $this->get( $key );
                if ( $this->isInteger( $n ) ) {
-                       $n = max( $n + intval( $value ), 0 );
+                       $n = max( $n + (int)$value, 0 );
                        $this->bag[$key][self::KEY_VAL] = $n;
 
                        return $n;
@@ -120,6 +120,10 @@ class HashBagOStuff extends MediumSpecificBagOStuff {
                return false;
        }
 
+       public function decr( $key, $value = 1, $flags = 0 ) {
+               return $this->incr( $key, -$value, $flags );
+       }
+
        /**
         * Clear all values in cache
         */