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

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

Introduction

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

Prototype

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

Source Link

Document

Determine the index of element with value in a sorted set.

Usage

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

public Long rank(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   ww w  .  j  a v  a2  s.  c  o m
            Long zRank = connection.zRank(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.
 * <p>//  www .java 2 s. c o  m
 * See http://redis.io/commands/zrank
 * 
 * @param key 
 * @param value value
 * @return Long
 */
public static Long zRank(byte[] key, byte[] value) {
    return redisTemplate.execute(new RedisCallback<Long>() {
        @Override
        public Long doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.zRank(key, value);
        }
    });
}

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

/**
 * Determine the index of element with {@code value} in a sorted set.
 * <p>//from  w ww  .j  ava2  s.c  o  m
 * See http://redis.io/commands/zrank
 * 
 * @param key 
 * @param value value
 * @return Long
 */
public Long zRank(byte[] key, byte[] value) {
    return redisTemplate.execute(new RedisCallback<Long>() {
        @Override
        public Long doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.zRank(key, value);
        }
    });
}