Add WRITE_SYNC flag to BagOStuff::set()/merge()
[lhc/web/wiklou.git] / includes / objectcache / MemcachedPeclBagOStuff.php
index 7e6a4d7..365236d 100644 (file)
@@ -115,40 +115,23 @@ class MemcachedPeclBagOStuff extends MemcachedBagOStuff {
                $this->client->addServers( $servers );
        }
 
-       public function get( $key, &$casToken = null, $flags = 0 ) {
+       protected function getWithToken( $key, &$casToken, $flags = 0 ) {
                $this->debugLog( "get($key)" );
                $result = $this->client->get( $this->encodeKey( $key ), null, $casToken );
                $result = $this->checkResult( $key, $result );
                return $result;
        }
 
-       /**
-        * @param string $key
-        * @param mixed $value
-        * @param int $exptime
-        * @return bool
-        */
-       public function set( $key, $value, $exptime = 0 ) {
+       public function set( $key, $value, $exptime = 0, $flags = 0 ) {
                $this->debugLog( "set($key)" );
                return $this->checkResult( $key, parent::set( $key, $value, $exptime ) );
        }
 
-       /**
-        * @param float $casToken
-        * @param string $key
-        * @param mixed $value
-        * @param int $exptime
-        * @return bool
-        */
        protected function cas( $casToken, $key, $value, $exptime = 0 ) {
                $this->debugLog( "cas($key)" );
                return $this->checkResult( $key, parent::cas( $casToken, $key, $value, $exptime ) );
        }
 
-       /**
-        * @param string $key
-        * @return bool
-        */
        public function delete( $key ) {
                $this->debugLog( "delete($key)" );
                $result = parent::delete( $key );
@@ -160,33 +143,17 @@ class MemcachedPeclBagOStuff extends MemcachedBagOStuff {
                }
        }
 
-       /**
-        * @param string $key
-        * @param int $value
-        * @param int $exptime
-        * @return mixed
-        */
        public function add( $key, $value, $exptime = 0 ) {
                $this->debugLog( "add($key)" );
                return $this->checkResult( $key, parent::add( $key, $value, $exptime ) );
        }
 
-       /**
-        * @param string $key
-        * @param int $value
-        * @return mixed
-        */
        public function incr( $key, $value = 1 ) {
                $this->debugLog( "incr($key)" );
                $result = $this->client->increment( $key, $value );
                return $this->checkResult( $key, $result );
        }
 
-       /**
-        * @param string $key
-        * @param int $value
-        * @return mixed
-        */
        public function decr( $key, $value = 1 ) {
                $this->debugLog( "decr($key)" );
                $result = $this->client->decrement( $key, $value );
@@ -236,8 +203,13 @@ class MemcachedPeclBagOStuff extends MemcachedBagOStuff {
        public function getMulti( array $keys, $flags = 0 ) {
                $this->debugLog( 'getMulti(' . implode( ', ', $keys ) . ')' );
                $callback = array( $this, 'encodeKey' );
-               $result = $this->client->getMulti( array_map( $callback, $keys ) );
-               $result = $result ?: array(); // must be an array
+               $encodedResult = $this->client->getMulti( array_map( $callback, $keys ) );
+               $encodedResult = $encodedResult ?: array(); // must be an array
+               $result = array();
+               foreach ( $encodedResult as $key => $value ) {
+                       $key = $this->decodeKey( $key );
+                       $result[$key] = $value;
+               }
                return $this->checkResult( false, $result );
        }