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)