redis 常用的数据类型
- 有序集合(sort set)、无序集合 (set),hashMap
redis pipelined 示例
List<Object> list = jedisTemplate.execute(new JedisTemplate.JedisAction<List<Object>>() {
@Override
public List<Object> action(Jedis jedis) {
Pipeline pipeline = jedis.pipelined();
pipeline.hgetAll(); // 获取 hashMap
pipeline.get(); // 获取 string
pipeline.smembers(); // 获取 set
return pipeline.syncAndReturnAll();
}
});
// 将 List<Object> 转化成各自对应的类型
Map<String String> map = (HashMap<String, String>) list.get(0);
String str = list.get(1).toString();
List<Object> list = Collections.singletonList(list.get(2));