// 使用Redis批处理方式获取用户信息
redis = jedisPool.getResource();
// 选择Redis库区间
redis.select(4);
// 管道
Pipeline pipe = redis.pipelined();
Map<Long, Response<String>> intrmMap = Maps.newHashMap();
users.stream().filter(Objects::nonNull).forEach(userVO->{
intrmMap.put(userVO.getId(), pipe.get("error" + userVO.getId() + userVO.getPartnerId()));
});
// 提交执行
pipe.sync();
Map<Long, String> map = Maps.newHashMap();
for (Map.Entry<Long, Response<String>> entry :intrmMap.entrySet()) {
Response<String> sResponse = (Response<String>)entry.getValue();
Long key = entry.getKey();
String value = sResponse.get();
map.put(key, value);
}
记录一下Redis一次取多个key - value的使用方法
最新推荐文章于 2024-04-02 19:47:26 发布