//查询Redis String key="dish_"+categoryId; //存在返回 List<DishVO> list = (List<DishVO>) redisTemplate.opsForValue().get(key); if (list!=null&&list.size()>0){ return Result.success(list); } //不存在查询数据库,放入Redis Dish dish = new Dish(); dish.setCategoryId(categoryId); dish.setStatus(StatusConstant.ENABLE);//查询起售中的菜品 list = dishService.listWithFlavor(dish); redisTemplate.opsForValue().set(key,list); return Result.success(list); }