Example usage for org.springframework.data.redis.connection RedisConnection zRevRank

List of usage examples for org.springframework.data.redis.connection RedisConnection zRevRank

Introduction

In this page you can find the example usage for org.springframework.data.redis.connection RedisConnection zRevRank.

Prototype

@Nullable
Long zRevRank(byte[] key, byte[] value);

Source Link

Document

Determine the index of element with value in a sorted set when scored high to low.

Usage

From source file:com.mauersu.util.redis.DefaultZSetOperations.java

public Long reverseRank(K key, Object o) {
    final byte[] rawKey = rawKey(key);
    final byte[] rawValue = rawValue(o);

    return execute(new RedisCallback<Long>() {

        public Long doInRedis(RedisConnection connection) {
            connection.select(dbIndex);/*from  w ww .ja v  a2s.c  om*/
            Long zRank = connection.zRevRank(rawKey, rawValue);
            return (zRank != null && zRank.longValue() >= 0 ? zRank : null);
        }
    }, true);
}

From source file:com.zxy.commons.cache.RedisUtils.java

/**
 * Determine the index of element with {@code value} in a sorted set when scored high to low.
 * <p>/* ww w . j av  a2s. c  o  m*/
 * See http://redis.io/commands/zrevrank
 * 
 * @param key key
 * @param value value
 * @return Long
 */
public static Long zRevRank(byte[] key, byte[] value) {
    return redisTemplate.execute(new RedisCallback<Long>() {
        @Override
        public Long doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.zRevRank(key, value);
        }
    });
}

From source file:com.zxy.commons.cache.RedisHelper.java

/**
 * Determine the index of element with {@code value} in a sorted set when scored high to low.
 * <p>/*  w  w  w  . j ava  2s .  c o  m*/
 * See http://redis.io/commands/zrevrank
 * 
 * @param key key
 * @param value value
 * @return Long
 */
public Long zRevRank(byte[] key, byte[] value) {
    return redisTemplate.execute(new RedisCallback<Long>() {
        @Override
        public Long doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.zRevRank(key, value);
        }
    });
}