objectcache: switch WANObjectCache process cache to MapCacheLRU
[lhc/web/wiklou.git] / includes / libs / objectcache / RedisBagOStuff.php
index f720010..a8047b0 100644 (file)
@@ -91,12 +91,19 @@ class RedisBagOStuff extends BagOStuff {
        }
 
        protected function doGet( $key, $flags = 0 ) {
+               $casToken = null;
+
+               return $this->getWithToken( $key, $casToken, $flags );
+       }
+
+       protected function getWithToken( $key, &$casToken, $flags = 0 ) {
                list( $server, $conn ) = $this->getConnection( $key );
                if ( !$conn ) {
                        return false;
                }
                try {
                        $value = $conn->get( $key );
+                       $casToken = $value;
                        $result = $this->unserialize( $value );
                } catch ( RedisException $e ) {
                        $result = false;
@@ -260,6 +267,10 @@ class RedisBagOStuff extends BagOStuff {
                return $result;
        }
 
+       public function merge( $key, callable $callback, $exptime = 0, $attempts = 10, $flags = 0 ) {
+               return $this->mergeViaCas( $key, $callback, $exptime, $attempts );
+       }
+
        /**
         * Non-atomic implementation of incr().
         *
@@ -279,7 +290,7 @@ class RedisBagOStuff extends BagOStuff {
                }
                try {
                        if ( !$conn->exists( $key ) ) {
-                               return null;
+                               return false;
                        }
                        // @FIXME: on races, the key may have a 0 TTL
                        $result = $conn->incrBy( $key, $value );
@@ -396,9 +407,7 @@ class RedisBagOStuff extends BagOStuff {
         */
        protected function getMasterLinkStatus( RedisConnRef $conn ) {
                $info = $conn->info();
-               return isset( $info['master_link_status'] )
-                       ? $info['master_link_status']
-                       : null;
+               return $info['master_link_status'] ?? null;
        }
 
        /**