From face4812c6b3cc60d4408601b3d4c7c484596417 Mon Sep 17 00:00:00 2001 From: Matthew Flaschen Date: Tue, 22 Oct 2013 17:35:23 -0400 Subject: [PATCH] Fix Redis increment behavior by using BagOStuff->incr instead Due to the PHP serialization, the Redis native INCR and INCRBY do not work. This instead falls back on the parent class's incr, which uses lock and unlock, and incrementing on the PHP side. Bug: 55986 Change-Id: I500199aeb935963ca118fde163bd7ba0cba8f79f --- includes/objectcache/RedisBagOStuff.php | 32 ------------------------- 1 file changed, 32 deletions(-) diff --git a/includes/objectcache/RedisBagOStuff.php b/includes/objectcache/RedisBagOStuff.php index e1dc42e15b..135e0e8302 100644 --- a/includes/objectcache/RedisBagOStuff.php +++ b/includes/objectcache/RedisBagOStuff.php @@ -273,38 +273,6 @@ class RedisBagOStuff extends BagOStuff { return $result; } - /** - * Non-atomic implementation of incr(). - * - * Probably all callers actually want incr() to atomically initialise - * values to zero if they don't exist, as provided by the Redis INCR - * command. But we are constrained by the memcached-like interface to - * return null in that case. Once the key exists, further increments are - * atomic. - */ - public function incr( $key, $value = 1 ) { - wfProfileIn( __METHOD__ ); - list( $server, $conn ) = $this->getConnection( $key ); - if ( !$conn ) { - wfProfileOut( __METHOD__ ); - return false; - } - if ( !$conn->exists( $key ) ) { - wfProfileOut( __METHOD__ ); - return null; - } - try { - $result = $conn->incrBy( $key, $value ); - } catch ( RedisException $e ) { - $result = false; - $this->handleException( $server, $conn, $e ); - } - - $this->logRequest( 'incr', $key, $server, $result ); - wfProfileOut( __METHOD__ ); - return $result; - } - /** * Get a Redis object with a connection suitable for fetching the specified key * @return Array (server, RedisConnRef) or (false, false) -- 2.20.1