标签:ping color hash font div 字符 有序 add for
@GetMapping("/string")
public String stringTest(){
redisTemplate.opsForValue().set("str","Hello World");
String str = (String) redisTemplate.opsForValue().get("str");
return str;
}
@GetMapping("/list")
public List<String> listTest(){
ListOperations<String,String> listOperations = redisTemplate.opsForList();
listOperations.leftPush("list","Hello");
listOperations.leftPush("list","World");
listOperations.leftPush("list","Java");
List<String> list = listOperations.range("list",0,2);
return list;
}
@GetMapping("/set")
public Set<String> setTest(){
SetOperations<String,String> setOperations = redisTemplate.opsForSet();
setOperations.add("set","Hello");
setOperations.add("set","Hello");
setOperations.add("set","World");
setOperations.add("set","World");
setOperations.add("set","Java");
setOperations.add("set","Java");
Set<String> set = setOperations.members("set");
return set;
}
@GetMapping("/zset")
public Set<String> zsetTest(){
ZSetOperations<String,String> zSetOperations = redisTemplate.opsForZSet();
zSetOperations.add("zset","Hello",1);
zSetOperations.add("zset","World",2);
zSetOperations.add("zset","Java",3);
Set<String> set = zSetOperations.range("zset",0,2);
return set;
}
HashMap key value
HashOperations key hashkey value
key 是每?组数据的 ID,hashkey 和 value 是?组完整的 HashMap 数据,通过 key 来区分不同的 HashMap。
HashMap hashMap1 = new HashMap();
hashMap1.put(key1,value1);
HashMap hashMap2 = new HashMap();
hashMap2.put(key2,value2);
HashMap hashMap3 = new HashMap();
hashMap3.put(key3,value3);
HashOperations<String,String,String> hashOperations =
redisTemplate.opsForHash();
hashOperations.put(hashMap1,key1,value1);
hashOperations.put(hashMap2,key2,value2);
hashOperations.put(hashMap3,key3,value3);
标签:ping color hash font div 字符 有序 add for
原文地址:https://www.cnblogs.com/hanfeizi/p/14352430.html