From: Matthew Flaschen Date: Tue, 22 Oct 2013 21:35:23 +0000 (-0400) Subject: Fix Redis increment behavior by using BagOStuff->incr instead X-Git-Tag: 1.31.0-rc.0~18434^2 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22suivi_revisions%22%29%20.%20%22?a=commitdiff_plain;h=face4812c6b3cc60d4408601b3d4c7c484596417;p=lhc%2Fweb%2Fwiklou.git 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 --- 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)