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

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

Introduction

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

Prototype

@Nullable
List<byte[]> mGet(byte[]... keys);

Source Link

Document

Get multiple keys .

Usage

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

public List<V> multiGet(Collection<K> keys) {
    if (keys.isEmpty()) {
        return Collections.emptyList();
    }// w  w  w  .  j  a va 2 s . co m

    final byte[][] rawKeys = new byte[keys.size()][];

    int counter = 0;
    for (K hashKey : keys) {
        rawKeys[counter++] = rawKey(hashKey);
    }

    List<byte[]> rawValues = execute(new RedisCallback<List<byte[]>>() {

        public List<byte[]> doInRedis(RedisConnection connection) {
            connection.select(dbIndex);
            return connection.mGet(rawKeys);
        }
    }, true);

    return deserializeValues(rawValues);
}

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

/**
 * Get the values of all given {@code keys}.
 * <p>//w  ww.  ja v  a  2s . c om
 * See http://redis.io/commands/mget
 * 
 * @param keys keys
 * @return List<byte[]>
 */
public static List<byte[]> mGet(byte[]... keys) {
    return redisTemplate.execute(new RedisCallback<List<byte[]>>() {
        @Override
        public List<byte[]> doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.mGet(keys);
        }
    });
}

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

/**
 * Get the values of all given {@code keys}.
 * <p>/* w  ww.  ja v  a  2s  .  co m*/
 * See http://redis.io/commands/mget
 * 
 * @param keys keys
 * @return List<byte[]>
 */
public List<byte[]> mGet(byte[]... keys) {
    return redisTemplate.execute(new RedisCallback<List<byte[]>>() {
        @Override
        public List<byte[]> doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.mGet(keys);
        }
    });
}