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

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

Introduction

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

Prototype

@Nullable
List<byte[]> hMGet(byte[] key, byte[]... fields);

Source Link

Document

Get values for given fields from hash at key .

Usage

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

public List<HV> multiGet(K key, Collection<HK> fields) {
    if (fields.isEmpty()) {
        return Collections.emptyList();
    }/*  w  ww  .j a  v  a 2s . co  m*/

    final byte[] rawKey = rawKey(key);

    final byte[][] rawHashKeys = new byte[fields.size()][];

    int counter = 0;
    for (HK hashKey : fields) {
        rawHashKeys[counter++] = rawHashKey(hashKey);
    }

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

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

    return deserializeHashValues(rawValues);
}

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

/**
 * Get values for given {@code fields} from hash at {@code key}.
 * /*from ww  w  . j av  a  2  s . com*/
 * @see http://redis.io/commands/hmget
 * @param key key
 * @param fields fields
 * @return List<byte[]>
 */
public static List<byte[]> hMGet(byte[] key, byte[]... fields) {
    return redisTemplate.execute(new RedisCallback<List<byte[]>>() {
        @Override
        public List<byte[]> doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.hMGet(key, fields);
        }
    });
}

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

/**
 * Get values for given {@code fields} from hash at {@code key}.
 * /*  www.  jav a2  s.c om*/
 * @see http://redis.io/commands/hmget
 * @param key key
 * @param fields fields
 * @return List<byte[]>
 */
public List<byte[]> hMGet(byte[] key, byte[]... fields) {
    return redisTemplate.execute(new RedisCallback<List<byte[]>>() {
        @Override
        public List<byte[]> doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.hMGet(key, fields);
        }
    });
}