计时结束后,如果用户没有进行支付,则取消本次订单
当时后台计时部分的技术,用的就是java中的定时器类Timer ,使用schedule来设置定时任务。虽然说功能实现了,但还是有很多问题,因为Timer本质上还是启动了一个线程来进行处理。当预约用户过多时,系统内存就会飙升,而且当发布新功能时,如果重启服务器,所有的定时器都会丢失。
Redis键空间通知
。
1 2 3 4
|
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-redis</artifactId> </dependency>
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
#Redis配置 #数据库索引,默认为0 spring.redis.database=0 #服务器地址,默认localhost spring.redis.host=localhost #端口,默认6379 spring.redis.port=6379 #密码,默认为空 spring.redis.password= #连接池最大连接数,默认为8 spring.redis.jedis.pool.max-active=8 #连接池最大阻塞等待时间,使用负值表示没有限制 spring.redis.jedis.pool.max-wait=-1 #连接池最大空闲连接,默认为8 spring.redis.jedis.pool.max-idle=8 #连接池中的最小空闲连接,默认为0 spring.redis.jedis.pool.min-idle=0 #连接超时时间(毫秒) spring.redis.timeout=10
|