springBoot 開啓Redis二級緩存


@RestController
@RequestMapping("/redis")
public class RedisController {


    /**
     *cacheNames 相當於一個文件夾
     *key 注意 key裏邊一定要加一個單引號 不加就會報錯
     * 還要注意實體對象一定要實現序列化接口
     * @return
     * @throws InterruptedException
     */
    @GetMapping(value = "/test")
    @Cacheable(cacheNames = "jxd",key ="'test1'")
    public String test1() throws InterruptedException {
     List<TGisDestinationUpdate> s = destinationService.selectDistintUpdateALL();
         return "ok";
    }

}

 

 

@SpringBootApplication
@MapperScan("")
@EnableDiscoveryClient
@EnableCaching//開啓緩存 注意啓動一定要加
public class WtphotoApplication {

    public static void main(String[] args) {
        SpringApplication.run(WtphotoApplication.class, args);
    }

}
發佈了47 篇原創文章 · 獲贊 5 · 訪問量 1萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章