Merge "Don't fallback from uk to ru"
[lhc/web/wiklou.git] / includes / libs / objectcache / WinCacheBagOStuff.php
index 19cc66a..d84c959 100644 (file)
  */
 class WinCacheBagOStuff extends BagOStuff {
        protected function doGet( $key, $flags = 0 ) {
-               $casToken = null;
-
-               return $this->getWithToken( $key, $casToken, $flags );
-       }
-
-       protected function getWithToken( $key, &$casToken, $flags = 0 ) {
                $val = wincache_ucache_get( $key );
-
-               $casToken = $val;
-
                if ( is_string( $val ) ) {
                        $val = unserialize( $val );
                }
@@ -54,10 +45,6 @@ class WinCacheBagOStuff extends BagOStuff {
                return ( is_array( $result ) && $result === [] ) || $result;
        }
 
-       protected function cas( $casToken, $key, $value, $exptime = 0 ) {
-               return wincache_ucache_cas( $key, $casToken, serialize( $value ) );
-       }
-
        public function delete( $key ) {
                wincache_ucache_delete( $key );
 
@@ -65,6 +52,13 @@ class WinCacheBagOStuff extends BagOStuff {
        }
 
        public function merge( $key, callable $callback, $exptime = 0, $attempts = 10, $flags = 0 ) {
-               return $this->mergeViaCas( $key, $callback, $exptime, $attempts );
+               if ( wincache_lock( $key ) ) { // optimize with FIFO lock
+                       $ok = $this->mergeViaLock( $key, $callback, $exptime, $attempts, $flags );
+                       wincache_unlock( $key );
+               } else {
+                       $ok = false;
+               }
+
+               return $ok;
        }
 }