目录
功能介绍
Redis公共工具类 可操作任意类型 将操作缓存与数据库繁琐的代码步骤聚合封装起来 使用简单简洁 且redis数据为空时可取数据库并同步添加缓存(配合daos)
引入依赖
<!-- Json --> <dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson</artifactId> <version>1.2.74</version> </dependency> <!-- Redis --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-redis</artifactId> </dependency>
创建Daos
/**
* @author ZS
* @date 2021/8/12 9:55
* Detail: 此工具类配合redisClient工具类使用 redis有值则此方法不执行 redis查询数据为空时 此工具类则作为第二选择执行dao方法
*/
@Component
public class Daos {
@Autowired
private TraderUserDao traderUserDao;
@Autowired
private TraderDao traderDao;
@Autowired
private CouponDao couponDao;
@Autowired
private CouponParkingDao couponParkingDao;
@Autowired
private RoadsideParkNumberDao roadsideParkNumberDao;
@Autowired
private RoadsideCityDao roadsideCityDao;
@Autowired
private CarparkDao carparkDao;
@Autowired
private TraderCouponParkingDao traderCouponParkingDao;
@Autowired
private TraderCouponBuyDao traderCouponB