X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fobjectcache%2FBagOStuff.php;h=0a2344688b913f7dee37b6bad79082ce7eb73986;hb=4d78d40d821227a9368e87306f447ffd3be5db88;hp=6f8f9afd2d159bbf087f3f6e6d32e07df1eaae68;hpb=ec9002258c8a0264cb2d92df6a216e9fa11d3462;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/objectcache/BagOStuff.php b/includes/objectcache/BagOStuff.php index 6f8f9afd2d..0a2344688b 100644 --- a/includes/objectcache/BagOStuff.php +++ b/includes/objectcache/BagOStuff.php @@ -173,13 +173,14 @@ abstract class BagOStuff { /** * @param string $key - * @param int $timeout [optional] + * @param int $timeout Lock wait timeout [optional] + * @param int $expiry Lock expiry [optional] * @return bool Success */ - public function lock( $key, $timeout = 6 ) { + public function lock( $key, $timeout = 6, $expiry = 6 ) { $this->clearLastError(); $timestamp = microtime( true ); // starting UNIX timestamp - if ( $this->add( "{$key}:lock", 1, $timeout ) ) { + if ( $this->add( "{$key}:lock", 1, $expiry ) ) { return true; } elseif ( $this->getLastError() ) { return false; @@ -198,11 +199,11 @@ abstract class BagOStuff { } usleep( $sleep ); // back off $this->clearLastError(); - $locked = $this->add( "{$key}:lock", 1, $timeout ); + $locked = $this->add( "{$key}:lock", 1, $expiry ); if ( $this->getLastError() ) { return false; } - } while ( !$locked ); + } while ( !$locked && ( microtime( true ) - $timestamp ) < $timeout ); return $locked; } @@ -277,21 +278,6 @@ abstract class BagOStuff { return false; // key already set } - /** - * @param string $key - * @param mixed $value - * @param int $exptime - * @return bool Success - * @deprecated since 1.23 - */ - public function replace( $key, $value, $exptime = 0 ) { - wfDeprecated( __METHOD__, '1.23' ); - if ( $this->get( $key ) !== false ) { - return $this->set( $key, $value, $exptime ); - } - return false; // key not already set - } - /** * Increase stored value of $key by $value while preserving its TTL * @param string $key Key to increase