implementation group: 'org.springframework.boot', name: 'spring-boot-starter-data-redis', version: '2.4.10'
spring: redis: host: localhost password: port: 6379
@Autowired private RedisTemplate redisTemplate; ........... @Override public Map getAllPolyline() { Map map = new HashMap(); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); OcPolylineData polyline = (OcPolylineData)redisTemplate.opsForValue().get("Polyline1"); log.info("第一次从查询redis"+polyline); List<OcPolylineData> ocPolylineDataList = polylineDataMapper.selectAllType(); redisTemplate.opsForValue().set("Polyline1",ocPolylineDataList); map.put("polylineDataList",ocPolylineDataList); map.put("Code", 200); map.put("Desc", "成功"); return map; }
第一此查询
第二次 可以看到redis里面是有的
emm其他的方式后续会更新