返回有序集 key 中成员 member 的排名。其中有序集成员按 score 值递增(从小到大)顺序排列。
排名以 0 为底，也就是说， score 值最小的成员排名为 0 。
使用 ZREVRANK 命令可以获得成员按 score 值递减(从大到小)排列的排名。
187761
public Long zrank(Object key, Object member) {
		Jedis jedis = getJedis();
		try {
			return jedis.zrank(keyToBytes(key), valueToBytes(member));
		}
		finally {close(jedis);}
	}
462175
function sk(key) {
    if (globalKeySanitize) {
      return key;
    } else {
      return key.replace(/\s+/g, '_')
                .replace(/\//g, '-')
                .replace(/[^a-zA-Z_\-0-9\.]/g, '');
    }
  }
585641
public void setPathScore(Term from, Map<String, Double> relationMap) {
        // 维特比进行最优路径的构建
        double score = MathUtil.compuScore(from, this, relationMap);
        if (this.from == null || this.score == 0 || this.score >= score) {
            this.setFromAndScore(from, score);
        }
    }
625458
public Long zrem(Object key, Object... members) {
		Jedis jedis = getJedis();
		try {
			return jedis.zrem(keyToBytes(key), valuesToBytesArray(members));
		}
		finally {close(jedis);}
	}
6816
def get_name(self, key):
        '''
        '''
        try:
            return self.nameDict[key]
        except IndexError as e:
            print 'IndexError {0}: {1}'.format(e.errno, e.strerror)
970055
def rank_member(self, member, score, member_data=None):
        '''
        
        '''
        self.rank_member_in(self.leaderboard_name, member, score, member_data)
836011
private int rank(Key key, RedBlackTreeNode<Key, Value> x) {
	if (x == null)
	    return 0;
	int cmp = key.compareTo(x.getKey());
	if (cmp < 0)
	    return rank(key, x.getLeft());
	else if (cmp > 0)
	    return 1 + size(x.getLeft()) + rank(key, x.getRight());
	else
	    return size(x.getLeft());
    }
1285821
function sismember(key, member, req) {
  var val = this.getKey(key, req);
  if(val === undefined) return 0;
  return val.sismember(member);
}
561741
def rank(self, member):
        
        score = self._members.get(member)
        if score is None:
            return None
        return bisect_left(self._scores, (score, member))
978159
public function zRangeByScore($key, $min = 0, $max = -1, $withScores = false, $offset = null, $count = null) {
        $payload = ['zrangebyscore', $key, $min, $max];

        if ($withScores) {
            $payload[] = 'WITHSCORES';
        }

        if ($offset !== null && $count !== null) {
            $payload[] = 'LIMIT';
            $payload[] = $offset;
            $payload[] = $count;
        }

        return $this->send($payload, function ($response) use ($withScores) {
            if ($withScores) {
                $result = [];

                for ($i = 0, $count = \count($response); $i < $count; $i += 2) {
                    $result[$response[$i]] = $response[$i + 1];
                }

                return $result;
            }

            return $response;
        });
    }
820321
def rank_for_in(self, leaderboard_name, member):
        '''
        
        '''
        member_score = self.score_for_in(leaderboard_name, member)
        if self.order == self.ASC:
            try:
                return self.redis_connection.zrank(
                    self._ties_leaderboard_key(leaderboard_name), str(float(member_score))) + 1
            except:
                return None
        else:
            try:
                return self.redis_connection.zrevrank(
                    self._ties_leaderboard_key(leaderboard_name), str(float(member_score))) + 1
            except:
                return None
656630
def get_score(self, member, default=None, pipe=None):
        
        pipe = self.redis if pipe is None else pipe
        score = pipe.zscore(self.key, self._pickle(member))

        if (score is None) and (default is not None):
            score = float(default)

        return score
809039
def _member_data_key(self, leaderboard_name):
        '''
        
        '''
        if self.global_member_data is False:
            return '%s:%s' % (leaderboard_name, self.member_data_namespace)
        else:
            return self.member_data_namespace
960122
private static String buildKey(String key, Map<String, Object> parameters) {
        // 匹配符合  :name 格式的参数
        Matcher matcher = PATTERN.matcher(key);
        if (matcher.find()) {

            StringBuilder builder = new StringBuilder();

            int index = 0;

            do {
                // 提取参数名称
                final String name = matcher.group(1).trim();

                Object value = null;

                // 解析  a.b.c 类型的名称 
                int find = name.indexOf('.');
                if (find >= 0) {

                    // 用  BeanWrapper 获取属性值
                    Object bean = parameters.get(name.substring(0, find));
                    if (bean != null) {
                        value = new BeanWrapperImpl(bean)
                                .getPropertyValue(name.substring(find + 1));
                    }

                } else {

                    // 获取参数值
                    value = parameters.get(name);
                }

                // 拼装参数值
                builder.append(key.substring(index, matcher.start()));
                builder.append(value);

                index = matcher.end();

            } while (matcher.find());

            // 拼装最后一段
            builder.append(key.substring(index));

            return builder.toString();
        }

        return key;
    }
737281
def rank_member_in(
            self, leaderboard_name, member, score, member_data=None):
        '''
        
        '''
        member_score = None or self.redis_connection.zscore(leaderboard_name, member)
        can_delete_score = member_score is not None and\
            (len(self.members_from_score_range_in(leaderboard_name, member_score, member_score)) == 1) and\
            member_score != score

        pipeline = self.redis_connection.pipeline()
        if isinstance(self.redis_connection, Redis):
            pipeline.zadd(leaderboard_name, member, score)
            pipeline.zadd(self._ties_leaderboard_key(leaderboard_name),
                          str(float(score)), score)
        else:
            pipeline.zadd(leaderboard_name, score, member)
            pipeline.zadd(self._ties_leaderboard_key(leaderboard_name),
                          score, str(float(score)))
        if can_delete_score:
            pipeline.zrem(self._ties_leaderboard_key(leaderboard_name),
                          str(float(member_score)))
        if member_data:
            pipeline.hset(
                self._member_data_key(leaderboard_name),
                member,
                member_data)
        pipeline.execute()
402526
public Double score(final String member) {
        return doWithJedis(new JedisCallable<Double>() {
            @Override
            public Double call(Jedis jedis) {
                return jedis.zscore(getKey(), member);
            }
        });
    }
212788
function(key, data, callback) {
	'use strict';

	/**
	 * Read scores by values.
	 *
	 * @param {Array} values
	 * @param {Function} callback
	 */
	var ReadScores = function(values, callback) {
		var result = [];

		/**
		 * Get scores recursive.
		 */
		var GetRecursive = function() {
			if (!values.length) {
				callback(null, result);
				return;
			}

			var value = values.pop();

			this.getClient().zscore(key, value, function(err, score) {
				if (err) {
					callback(err);
					return;
				}

				result.push(score);
				GetRecursive();
			});
		}.bind(this);

		GetRecursive();
	}.bind(this);

	/**
	 * Read key.
	 *
	 * @param {String} key
	 * @param {String} type
	 * @param {Function} rkCallback
	 */
	var ReadKey = function(key, type, rkCallback) {
		var params = [ key ],
			command = {
				set: 'smembers',
				zset: 'zrange',
				list: 'lrange',
				hash: 'hgetall'
			}[ type ] || 'get';

		if (command.indexOf('range') !== -1) {
			params.push(0);
			params.push(-1);
		}

		params.push(function(err, values) {
			if (err) {
				rkCallback(err);
				return;
			}

			switch (type) {
				case 'zset':
					ReadScores(_.clone(values).reverse(), function(err, scores) {
						rkCallback(null, _.zip(scores, values));
					});
					break;

				default:
					rkCallback(null, values);
					break;
			}
		});

		this.getClient()[ command ].apply(this.getClient(), params);
	}.bind(this);


	switch (this.getExportParams().type) {
		//	Export as redis type.
		case 'redis':
			return function(err, type) {
				var type2PrintSetCommand = {
					string: 'SET',
					set: 'SADD',
					zset: 'ZADD',
					list: 'RPUSH',
					hash: 'HSET'
				};

				if (!data) {
					data = '';
				}

				ReadKey(key, type, function(err, value) {
					if (err) {
						callback(err);
						return;
					}

					var command = type2PrintSetCommand[ type ];

					key = key.trim();

					switch (type) {
						case 'set':
							_.each(value, function(item) {
								data += command + ' "' + key + '" "' + item + "\"\n";
							});
							break;

						case 'zset':
							_.each(value, function(item) {
								data += command + ' "' + key + '" ' + item[0] + ' "' + item[1] + "\"\n";
							});
							break;

						case 'hash':
							_.each(_.pairs(value), function(item) {
								data += command + ' "' + key + '" "' + item[0] + '" "' + item[1] + "\"\n";
							});
							break;

						default:
							data += command + ' "' + key + '" "' + value + "\"\n";
							break;
					}

					callback(null, data);
				});
			};

		//	Export as json type.
		case 'json':
			return function(err, type) {
				if (!data) {
					data = {};
				}

				ReadKey(key, type, function(err, value) {
					if (err) {
						callback(err);
						return;
					}

					switch (type) {
						case 'zset':
							var withoutScores = [];
							_.each(value, function(item) {
								withoutScores.push(item[1]);
							});
							value = withoutScores;
							break;
					}

					data[ key.trim() ] = value;

					callback(null, data);
				});
			};
	}
}