202010-10 SpringBoot如何整合redis实现过期key监听事件 可以用于简单的过期订单取消支付、7天自动收货场景中1、SpringBoot整合redis参考https://www.jb51.net/article/170687.htm2、打开redis服务的配置文件添加notify-keyspace-eventsEx如果是注释了,就取消注释Linux安装redis:https://www.jb51.net/article/193265.htmWindows安装redis:https://www.jb51.net/article/176040.htm3、在redis配置类@Configuration添加如下内容@BeanRedisMessageListenerContainercontainer(R... 继续阅读 >
202010-09 spring boot+redis 监听过期Key的操作方法 前言:在订单业务中,有时候需要对订单设置有效期,有效期到了后如果还未支付,就需要修改订单状态。对于这种业务的实现,有多种不同的办法,比如:1、使用querytz,每次生成一个订单,就创建一个定时任务,到期后执行业务代码;2、rabbitMq中的延迟队列;3、对Redis的Key进行监控; 1、引入依赖<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-data-redis</artifactId></... 继续阅读 >