From 4ac9fa081a7c045f6a9f1cfc529d82423f485b2e Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sun, 8 Dec 2013 09:55:49 +0100 Subject: Update to MediaWiki 1.22.0 --- includes/objectcache/RedisBagOStuff.php | 40 ++++++--------------------------- 1 file changed, 7 insertions(+), 33 deletions(-) (limited to 'includes/objectcache/RedisBagOStuff.php') diff --git a/includes/objectcache/RedisBagOStuff.php b/includes/objectcache/RedisBagOStuff.php index f9feaf9d..135e0e83 100644 --- a/includes/objectcache/RedisBagOStuff.php +++ b/includes/objectcache/RedisBagOStuff.php @@ -140,7 +140,13 @@ class RedisBagOStuff extends BagOStuff { $conn->setex( $key, $expiry, $value ); } - $result = $conn->exec(); + /* + * multi()/exec() (transactional mode) allows multiple values to + * be set/get at once and will return an array of results, in + * the order they were set/get. In this case, we only set 1 + * value, which should (in case of success) result in true. + */ + $result = ( $conn->exec() == array( true ) ); } catch ( RedisException $e ) { $result = false; $this->handleException( $server, $conn, $e ); @@ -267,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) -- cgit v1.2.2