不知道咋搞搞的,我找到的是 好像是國內一個開發者所做的
<groupId>com.zengtengpeng</groupId>
看依賴的域名差不多明白吧
https://gitee.com/ztp/redisson-spring-boot-starter
使用起來 就三步 ,導依賴,配置,使用
依賴:
<dependency>
<groupId>com.zengtengpeng</groupId>
<artifactId>redisson-spring-boot-starter</artifactId>
<version>1.0.7</version>
</dependency>
配置 我用的yml
redisson:
single-server-config:
address: 127.0.0.1:6379
Controller層使用:
redissonCollection.getList() 獲取到的數據類型是RList,直接以JSON返回給前端,使用和list相同
另外還有Object和二進制的用法,參見使用說明
@Autowired private CategoryService categoryService; @Autowired private RedissonCollection redissonCollection; @GetMapping("/findAll") public ResultInfo findall(){ RList<Category> cateList = redissonCollection.getList("cateList"); if (cateList.size()==0){ System.out.println("redis中沒有, 走Mysql"); List<Category> list = categoryService.list(); redissonCollection.setListValues("cateList",list); }
//封裝返回結果 ResultInfo resultInfo = new ResultInfo(); resultInfo.setFlag(true); resultInfo.setCode(3001); resultInfo.setData(cateList); return resultInfo; }