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

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

Introduction

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

Prototype

@Nullable
byte[] randomKey();

Source Link

Document

Return a random key from the keyspace.

Usage

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

/**
 * Return a random key from the keyspace.
 * <p>//  w  w  w  .  j  av  a2 s  .  c  o  m
 * See http://redis.io/commands/randomkey
 * 
 * @return byte[]
 */
public static byte[] randomKey() {
    return redisTemplate.execute(new RedisCallback<byte[]>() {
        @Override
        public byte[] doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.randomKey();
        }
    });
}

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

/**
 * Return a random key from the keyspace.
 * <p>//from   w  w  w .j a v  a 2s  .  co  m
 * See http://redis.io/commands/randomkey
 * 
 * @return byte[]
 */
public byte[] randomKey() {
    return redisTemplate.execute(new RedisCallback<byte[]>() {
        @Override
        public byte[] doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.randomKey();
        }
    });
}