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

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

Introduction

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

Prototype

@Nullable
byte[] sRandMember(byte[] key);

Source Link

Document

Get random element from set at key .

Usage

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

public V randomMember(K key) {

    return execute(new ValueDeserializingRedisCallback(key) {

        protected byte[] inRedis(byte[] rawKey, RedisConnection connection) {
            connection.select(dbIndex);/*from  w w w. j a  v  a2 s. c  o m*/
            return connection.sRandMember(rawKey);
        }
    }, true);
}

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

/**
 * Get random element from set at {@code key}.
 * <p>/*from   ww  w  .ja v a2 s  .c om*/
 * See http://redis.io/commands/srandmember
 * 
 * @param key key
 * @return byte[]
 */
public static byte[] sRandMember(byte[] key) {
    return redisTemplate.execute(new RedisCallback<byte[]>() {
        @Override
        public byte[] doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.sRandMember(key);
        }
    });
}

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

/**
 * Get random element from set at {@code key}.
 * <p>//from  w w w  .ja v a 2s  .c o m
 * See http://redis.io/commands/srandmember
 * 
 * @param key key
 * @return byte[]
 */
public byte[] sRandMember(byte[] key) {
    return redisTemplate.execute(new RedisCallback<byte[]>() {
        @Override
        public byte[] doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.sRandMember(key);
        }
    });
}