Springboot 集成 Redis

@CachePut 和 @Cacheable 区别

操作步骤如下:

1. t1 t2 都为空值

@CachePut("t1")
public String getData1(){
    return service.getData1();    
}

@Cacheable("t2")
public String getData1(){
    return service.getData2();    
}

此时 t1 = "hello 1";
此时 t2 = "hello 2";

2. 修改返回值

service.getData1() = "hello 1-1";
service.getData2() = "hello 2-2";

此时 t1 = "hello 1-1";
此时 t2 = "hello 2"

结论:@CachePut 数据会更新,@Cacheable 数据不会更新

posted @ 2020-06-24 15:01  梦见舟  阅读(96)  评论(0编辑  收藏  举报