Added merge() function to BagOStuff for CAS-like functionality.
[lhc/web/wiklou.git] / includes / objectcache / MemcachedPeclBagOStuff.php
index 7793710..9f06fa0 100644 (file)
@@ -104,14 +104,16 @@ class MemcachedPeclBagOStuff extends MemcachedBagOStuff {
 
        /**
         * @param $key string
+        * @param $casToken[optional] float
         * @return Mixed
         */
-       public function get( $key ) {
+       public function get( $key, &$casToken = null ) {
                wfProfileIn( __METHOD__ );
                $this->debugLog( "get($key)" );
-               $value = $this->checkResult( $key, parent::get( $key ) );
+               $result = $this->client->get( $this->encodeKey( $key ), null, $casToken );
+               $result = $this->checkResult( $key, $result );
                wfProfileOut( __METHOD__ );
-               return $value;
+               return $result;
        }
 
        /**
@@ -125,6 +127,18 @@ class MemcachedPeclBagOStuff extends MemcachedBagOStuff {
                return $this->checkResult( $key, parent::set( $key, $value, $exptime ) );
        }
 
+       /**
+        * @param $casToken float
+        * @param $key string
+        * @param $value
+        * @param $exptime int
+        * @return bool
+        */
+       public function cas( $casToken, $key, $value, $exptime = 0 ) {
+               $this->debugLog( "cas($key)" );
+               return $this->checkResult( $key, parent::cas( $casToken, $key, $value, $exptime ) );
+       }
+
        /**
         * @param $key string
         * @param $time int