/*
* 默认连接localhost:6379
*/
private static void test1() {
Jedis jedis = new Jedis();
jedis.set("key1","haha");
System.out.println(jedis.get("key1"));
Test2Pojo test2Pojo = new Test2Pojo();
test2Pojo.setId(1);
test2Pojo.setName("haha");
jedis.set("key", JSON.toJSONString(test2Pojo));
System.out.println(jedis.get("key"));
List<Test2Pojo> list = new ArrayList<>();
list.add(test2Pojo);
jedis.set("key",JSON.toJSONString(list));
System.out.println(jedis.get("key"));
jedis.close();
}
@Data
static
class Test2Pojo implements Serializable {
private static final long serialVersionUID = 1L;
private int id;
private String name;
}
网友评论