public Object hincrebyAndReturn(final String key, final String field, final Long delta) { List<Object> result = redisTemplate.executePipelined( new RedisCallback<byte[]>() { @Override public byte[] doInRedis(RedisConnection connection) throws DataAccessException { connection.hIncrBy(key.getBytes(), field.getBytes(), delta); connection.hGet(key.getBytes(), field.getBytes()); return null; } }); return result.get(0); }
public Map<String, Map<byte[], byte[]>> hGetAll(final List<String> keys) { List<Object> results = redisTemplate.executePipelined( new RedisCallback<Map<byte[], byte[]>>() { @Override public Map<byte[], byte[]> doInRedis(RedisConnection redisConnection) throws DataAccessException { for (String key : keys) { redisConnection.hGetAll(key.getBytes()); } return null; } }); Map<String, Map<byte[], byte[]>> resultMap = new HashMap(); for (int i = 0; i < keys.size(); i++) { resultMap.put(keys.get(i), (Map<byte[], byte[]>) results.get(i)); } return resultMap; }