diff --git a/includes/libs/objectcache/RedisBagOStuff.php b/includes/libs/objectcache/RedisBagOStuff.php index c6cf84d80c9..89ae6520961 100644 --- a/includes/libs/objectcache/RedisBagOStuff.php +++ b/includes/libs/objectcache/RedisBagOStuff.php @@ -437,28 +437,23 @@ class RedisBagOStuff extends MediumSpecificBagOStuff { } $ttl = $this->getExpirationAsTTL( $exptime ); - try { - if ( $init === $step && $exptime == self::TTL_INDEFINITE ) { - $newValue = $conn->incrBy( $key, $step ); - } else { - $conn->multi( Redis::PIPELINE ); - $conn->set( - $key, - (string)( $init - $step ), - $ttl ? [ 'nx', 'ex' => $ttl ] : [ 'nx' ] - ); - $conn->incrBy( $key, $step ); - $batchResult = $conn->exec(); - $newValue = ( $batchResult === false ) ? false : $batchResult[1]; - $this->logRequest( 'incrWithInit', $key, $conn->getServer(), $newValue === false ); - } + static $script = + /** @lang Lua */ +<<eval( $script, [ $key, $ttl, $step, $init ], 1 ); } catch ( RedisException $e ) { - $newValue = false; + $result = false; $this->handleException( $conn, $e ); } + $this->logRequest( 'incrWithInit', $key, $conn->getServer(), $result ); - return $newValue; + return $result; } protected function doChangeTTL( $key, $exptime, $flags ) {